Docker安装Orcale数据库

发布于 2020-08-14  529 次阅读


数据库版本为Orcale 12.2.0.1

1、下载镜像

docker pull zhuyijun/oracle-12c

2、启动容器

1)12c版本

linux环境下docker启动容器命令

docker run   --name myoracle \
-p 1521:1521 -p 5500:5500 \
-e ORACLE_SID=orcl \
-e ORACLE_PDB=orclpdb1 \
-e ORACLE_PWD=123456 \
-e ORACLE_CHARACTERSET=al32utf8 \
-e ORACLE_BASE=/opt/oracle \
-e ORACLE_HOME=/opt/oracle/product/12.2.0.1/dbhome_1 \
-e PATH=/opt/oracle/product/12.2.0.1/dbhome_1/bin:/opt/oracle/product/12.2.0.1/dbhome_1/OPatch/:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
-v /home/nicemoe/oradata:/opt/oracle/oradata \
zhuyijun/oracle-12c:latest

windows环境下启动orcale容器命令

docker run   --name myoracle `
-p 1521:1521 -p 5500:5500 `
-e ORACLE_SID=orcl `
-e ORACLE_PDB=orclpdb1 `
-e ORACLE_PWD=123456 `
-e ORACLE_CHARACTERSET=al32utf8 `
-e ORACLE_BASE=/opt/oracle `
-e ORACLE_HOME=/opt/oracle/product/12.2.0.1/dbhome_1 `
-e PATH=/opt/oracle/product/12.2.0.1/dbhome_1/bin:/opt/oracle/product/12.2.0.1/dbhome_1/OPatch/:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin `
-v /d/docker/data/oradata:/opt/oracle/oradata `
oracle-12c:latest

注意使用之前修改/home/nicemoe/oradata为自己的

/d/docker/data/oradata意思是D:/docker/data/oradata文件夹

2)19c版本

linux环境下启动容器命令

docker run  --name myoracle \
-p 1521:1521 -p 5500:5500 \
-e ORACLE_SID=orcl \
-e ORACLE_PDB=orclpdb1 \
-e ORACLE_PWD=123456 \
-e ORACLE_CHARACTERSET=zhs16gbk \
-e ORACLE_BASE=/opt/oracle \
-e ORACLE_HOME=/opt/oracle/product/12.2.0.1/dbhome_1 \
-e PATH=/opt/oracle/product/12.2.0.1/dbhome_1/bin:/opt/oracle/product/12.2.0.1/dbhome_1/OPatch/:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
-v /home/nicemoe/oradata:/opt/oracle/oradata \
registry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle-12c:latest

windows环境下启动orcale容器命令

docker run   --name myoracle `
-p 1521:1521 -p 5500:5500 `
-e ORACLE_SID=orcl `
-e ORACLE_PDB=orclpdb1 `
-e ORACLE_PWD=123456 `
-e ORACLE_CHARACTERSET=zhs16gbk `
-e ORACLE_BASE=/opt/oracle `
-e ORACLE_HOME=/opt/oracle/product/12.2.0.1/dbhome_1 `
-e PATH=/opt/oracle/product/12.2.0.1/dbhome_1/bin:/opt/oracle/product/12.2.0.1/dbhome_1/OPatch/:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin `
-v /d/docker/data/oradata:/opt/oracle/oradata `
<container name>

命令解释:

-d: 后台运行容器,并返回容器ID;
-p: 指定端口映射,格式为:主机(宿主)端口:容器端口
--name: 为容器指定一个名称;
-e:设置环境变量
-v:绑定一个卷 例子:/home/nicemoe/oradata:/opt/oracle/oradata   /home/nicemoe/oradata为自己创建orcale数据目录,需要分配权限

3、修改密码

docker exec  <container name> ./setPassword.sh <your password>

例如:

docker exec  d38c6077ec85 ./setPassword.sh 123456

4、连接数据库

sqlplus sys/<your password>@//localhost:1521/<your SID> as sysdba
sqlplus system/<your password>@//localhost:1521/<your SID>
sqlplus pdbadmin/<your password>@//localhost:1521/<Your PDB name>
例子:
sqlplus sys/123456@//localhost:1521/orcl as sysdba
sqlplus system/123456@//localhost:1521/orcl
sqlplus pdbadmin/123456@//localhost:1521/orclpdb1

2、容器中的Oracle数据库还配置了Oracle Enterprise Manager Express。要访问OEM Express,请启动浏览器并按照以下URL进行操作:

https://localhost:5500/em/
用户名system/sys等
口令123456
容器名orclpdb1

若要以sysdba身份登录:

用户名sys
口令123456
容器名orclpdb1