centos7 docker 安装oracle11g
一、下载oracle镜像
sudo docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
二、检查镜像
sudo docker images
三、运行镜像
sudo docker run --restart=always -d -p 8080:8080 -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
命令解析
docker run #运行容器
--restart=always #启动策略 设置为保持重启
-d #后台运行
-p 8080:8080 #端口映射
-p 1521:1521 #端口映射
--name oracle11g #服务命名
-v /data/oracle:/data/oracle #若是须要挂载使用此参数
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
四、配置oracle服务
step1:进入容器
docker exec -it oracle11g /bin/bash
step2:修改环境变量
su root
#密码
helowin
vi /etc/profile
#行末 unset -f pathmunge 下一行 按i 粘贴以下环境变量
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH
#按esc 输入 :wq! 按enter
source /etc/profile #刷新环境变量
step3:配置软链接
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
5、修改oracle用户
#容器切换oracle用户
su oracle
#登陆oracle dba
sqlplus /nolog;
conn /as sysdba;
#修改初始帐号
alter user system identified by system;
alter user sys identified by system;
#添加本身的dba帐号
create user my_account identified by my_password;
grant connect,resource,dba to my_account;
#设置密码永不过时
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
#关闭
shutdown immediate;
#启动数据库