服务器:CentOS7.9
1.安装docker
yum install -y docker
2. 设置镜像加速
修改 /etc/docker/daemon.json
文件并添加上 registry-mirrors 键值
阿里云的docker镜像需要自己注册账号,也可以不注册账号,直接使用下面的连接。
也可以写入多个镜像地址
{
"registry-mirrors": ["https://nz5uykfk.mirror.aliyuncs.com","https://zksw64rd.mirror.aliyuncs.com"]
}
3.拉取镜像
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
4.运行镜像
docker run -p 1521:1521 \
--restart=always \
--name oracle_11g \
-v /opt/oracle_data:/home/oracle/app/oracle/oradata/mydata \
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
5.进入容器设置用户信息
docker exec -it oracle_11g bash
切换root用户,密码:helowin
su root
5.1配置oracle环境变量
vi /etc/profile
5.2在末位添加
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH
5.3刷新配置
source /etc/profile
5.4创建建立sqlplus软连接
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
5.5切换到oracle用户
su oracle
5.6换到oracle用户
sqlplus / as sysdba
5.7修改用户
alter user system identified by 123456;
alter user sys identified by 123456;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
5.8退出sqlplus
exit
5.9pl/sql developer连接(可不操作)
修改tnsnames.ora,添加连接串
ORCL_DOCKER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.71.148)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = helowin)
)
)
6.远程连接
数据库选择helowin
参考文档:Docker快速搭建Oracle服务_docker oracle 开启service name-CSDN博客