1.拉去oracle数据库镜像
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
2.启动oracle 自动启动镜像 --restart=always
docker run -p 1521:1521 --name oracle_11g -d --restart=always registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
3.启动服务
docker start oracle_11g
4.进入控制台设置用户信息
docker exec -it oracle_11g bash
5.切换到root用户模式下
su root
输入密码helowin
【Linux下配置oracle的环境变量】
编辑profile文件配置ORACLE环境变量
打开:vi /etc/profile ,
6.编辑profile文件配置ORACLE环境变量
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH
7.重启配置文件服务
source /etc/profile
8.建立sqlplus软连接
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
9.切换到oracle用户,修改oracle的相关账号密码
>su oracle
登录sqlplus并修改sys、system用户密码
>sqlplus /nolog
>conn /as sysdba
>alter user system identified by oracle;
>alter user sys identified by oracle;
>ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
使用docker安装oracle11g,在网上找了很多,踩了很多坑。
阿里镜像安装,参考https://blog.youkuaiyun.com/qq_38380025/article/details/80647620,亲测可用。
不过安装后服务名是helowin,大佬说可以在镜像中修改,这个后续学习。
那么,开始(只记录主要步骤):
1.镜像拉取:
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
2.创建容器
docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
-d: 后台运行容器,并返回容器ID;
-p: 指定端口映射,格式为:主机(宿主)端口:容器端口
--name: 为容器指定一个名称;
3.启动容器
docker start oracle11g
4.进入镜像进行配置
1) docker exec -it oracle11g bash
2) 进行软连接:sqlplus /nolog
提示用不了?
切换到root 用户下 su root 密码:helowin
(注意这里还是在容器当中,容器内$,终端内#)
编辑profile文件配置ORACLE环境变量(vi /etc/profile :wq),在最后加上:
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH创建软连接
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
切换到oracle 用户 su - oracle
3) 登录sqlplus并修改sys、system用户密码
sqlplus /nologconn /as sysdba
接着执行下面命令
alter user system identified by system;
alter user sys identified by sys;
(若出现错误:ORA-01507: database not mounted,则执行:
alter database mount;
alter database open;
)
执行 ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
4) 退出软连接 exit
原文还有介绍使用plsql和Navicat进行连接的介绍,
使用plsql进行连接需在tnsnames.ora(oracle客户端文件)配置数据库连接地址;
使用Navicat连接oracle需要配置oci文件