吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1046|回复: 13
收起左侧

[学习记录] docker 安装 Oracle数据库

  [复制链接]
yuluo829 发表于 2023-3-25 15:42

docker 安装 Oracle数据库

拉取镜像

## pull
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

## 查看
docker images | grep oracle

创建容器

docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

启动容器

docker start oracle11g

若在启动容器出现以下错误

(iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 1521 -j DNAT --to-destination 172.17.0.2:1521 ! -i docker0: iptables: No chain/target/match by that name.

重启 docker 即可

进入镜像进行配置

docker exec -it oracle11g bash
  1. 切换到 root 用户下

    su root

    helowin

  2. 编辑 profile 文件配置 oracle 环境变量

    ## 打开环境变量配置文件
    vi  /etc/profile
    
    ## 加入以下的环境变量配置
    export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhom_2
    export ORACLE_SID=helowin
    export PATH=$ORACLE_HOME/bin/$PATH
    
    # 环境变量生效
    source /etc/profile
  3. 创建软连接(快捷方式)

    ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
  4. 切换到 oracle 用户

    # 一定要加中间 - ,否则软连接无效
    su - oracle
  5. 登录  sqlplus 并修改 sys,system的用户密码

    sqlplus /nolog
    
    # 以 sysdba 的身份连接并操作数据库
    conn /as sysdba
    
    # 修改 system 的密码为 system
    alter user system identified by system;
    
    # 修改 sys 的密码为 sys
    alter user sys identified by sys;
    
    # 也可以创建用户
    create user test identified by test;
    
    # 给创建的用户赋予权限
    grant connect,resource,dba to test;
    
    # scott 用户的解锁
    alter user scott account unlock;
    # 解锁 scott 用户的密码【也可以用来重新设置密码】
    alter user scott identified by tiger;

oracle 连接

使用 navicat 的 Bacis 方式用 scott 用户测试连接【其中的服务名是helowin】

使用 select * from tab; 显示数据库中的所有表

停止容器

docker stop oracle11g

免费评分

参与人数 2吾爱币 +2 热心值 +2 收起 理由
chendeshen + 1 + 1 热心回复!
Rabb + 1 + 1 我很赞同!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Rabb 发表于 2023-3-25 16:02
学习了,感谢感谢
pasyou 发表于 2023-3-25 17:05
wlshang 发表于 2023-3-25 17:24
EXiaoLu 发表于 2023-3-25 17:30
好资源一起学习
alan3258 发表于 2023-3-25 17:44
正需要,开发测试使用挺好,感谢分享!
KONT1995 发表于 2023-3-25 18:15
学习到了很多,感谢
dadaliya 发表于 2023-3-25 18:17
感谢大佬,学到了
人时地事 发表于 2023-3-25 21:28
这个教程我看过,貌似局域网中的ip 连不上docker 中的oracle
adtic 发表于 2023-3-25 23:03
人时地事 发表于 2023-3-25 21:28
这个教程我看过,貌似局域网中的ip 连不上docker 中的oracle

你把防火墙啥的关了试试
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-23 19:22

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表