docker部署oracle--19c为例
1、oracle-docker-imagegithub地址:https://github.com/oracle/docker-images码云地址:https://gitee.com/mirrors/Docker-Oracle-Images2、oracle官网下载:LINUX.X64_193000_db_home.zip,放入:3、通过dockerfile进行镜像制作参考:https://gite
1、oracle-docker-image
github地址:https://github.com/oracle/docker-images
码云地址:https://gitee.com/mirrors/Docker-Oracle-Images
2、oracle官网下载:LINUX.X64_193000_db_home.zip,放入:
3、通过dockerfile进行镜像制作
参考:https://gitee.com/mirrors/Docker-Oracle-Images/blob/master/OracleDatabase/SingleInstance/README.md
[oracle@localhost dockerfiles]$ ./buildContainerImage.sh -h
Usage: buildContainerImage.sh -v [version] [-e | -s | -x] [-i] [-o] [container build option]
Builds a container image for Oracle Database.
Parameters:
-v: version to build
Choose one of: 11.2.0.2 12.1.0.2 12.2.0.1 18.3.0 18.4.0 19.3.0
-e: creates image based on 'Enterprise Edition'
-s: creates image based on 'Standard Edition 2'
-x: creates image based on 'Express Edition'
-i: ignores the MD5 checksums
-o: passes on container build option
* select one edition only: -e, -s, or -x
LICENSE UPL 1.0
Copyright (c) 2014,2021 Oracle and/or its affiliates.
当然以上有人已经做过了镜像并且上传到阿里云的共享容器中,也可以直接拉去别人的镜像
##别人的镜像
docker pull registry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle:19c
##我的镜像
docker pull registry.cn-hangzhou.aliyuncs.com/windhan/mine:orcl19c_v001
4、通过镜像生成容器,参考
docker run --name <container name> \
-p <host port>:1521 -p <host port>:5500 \
-e ORACLE_SID=<your SID> \
-e ORACLE_PDB=<your PDB name> \
-e ORACLE_PWD=<your database passwords> \
-e INIT_SGA_SIZE=<your database SGA memory in MB> \
-e INIT_PGA_SIZE=<your database PGA memory in MB> \
-e ORACLE_EDITION=<your database edition> \
-e ORACLE_CHARACTERSET=<your character set> \
-v [<host mount point>:]/opt/oracle/oradata \
oracle/database:19.3.0-ee
Parameters:
--name: The name of the container (default: auto generated).
-p: The port mapping of the host port to the container port.
Two ports are exposed: 1521 (Oracle Listener), 5500 (OEM Express).
-e ORACLE_SID: The Oracle Database SID that should be used (default: ORCLCDB).
-e ORACLE_PDB: The Oracle Database PDB name that should be used (default: ORCLPDB1).
-e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated).
-e INIT_SGA_SIZE:
The total memory in MB that should be used for all SGA components (optional).
Supported 19.3 onwards.
-e INIT_PGA_SIZE:
The target aggregate PGA memory in MB that should be used for all server processes attached to the instance (optional).
Supported 19.3 onwards.
-e ORACLE_EDITION:
The Oracle Database Edition (enterprise/standard).
Supported 19.3 onwards.
-e ORACLE_CHARACTERSET:
The character set to use when creating the database (default: AL32UTF8).
-v /opt/oracle/oradata
The data volume to use for the database.
Has to be writable by the Unix "oracle" (uid: 54321) user inside the container!
If omitted the database will not be persisted over container recreation.
-v /opt/oracle/scripts/startup | /docker-entrypoint-initdb.d/startup
Optional: A volume with custom scripts to be run after database startup.
For further details see the "Running scripts after setup and on startup" section below.
-v /opt/oracle/scripts/setup | /docker-entrypoint-initdb.d/setup
Optional: A volume with custom scripts to be run after database setup.
For further details see the "Running scripts after setup and on startup" section below.
注意项,-v挂载出来的目录要有其他用户写的权限,执行如下命令,我的挂载地址:/pub/oracle/oradata
chmod o+w /pub/oracle/oradata
docker run -d --name orcl19c_03 \
-p 1524:1521 -p 5502:5500 \
-e ORACLE_SID=ORCLCDB \
-e ORACLE_PDB=ORCLPDB1 \
-e ORACLE_PWD=密码 \
-e ORACLE_EDITION=standard \
-e ORACLE_CHARACTERSET=AL32UTF8 \
-v /pub/oracle/oradata:/opt/oracle/oradata \
image_id
查看镜像启动过程
###获取容器id
[root@bogon oracle]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ac123794dfc6 4a714810def1 "/bin/sh -c 'exec $O…" 50 minutes ago Up 50 minutes (healthy) 0.0.0.0:1524->1521/tcp, :::1524->1521/tcp, 0.0.0.0:5502->5500/tcp, :::5502->5500/tcp orcl19c_03
###查看上述容器启动日志
[root@bogon oracle]# docker logs -ft ac123794dfc6
2021-05-23T06:39:56.800204186Z ORACLE EDITION: STANDARD
2021-05-23T06:39:56.840131694Z ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: fjelite
2021-05-23T06:39:56.939071800Z
2021-05-23T06:39:56.939091104Z LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 23-MAY-2021 06:39:56
##启动成功
2021-05-23T06:53:32.107439928Z SQL> SQL> Disconnected from Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
2021-05-23T06:53:32.107501883Z Version 19.3.0.0.0
2021-05-23T06:53:33.080815365Z The Oracle base remains unchanged with value /opt/oracle
2021-05-23T06:53:34.104292368Z #########################
2021-05-23T06:53:34.104320849Z DATABASE IS READY TO USE!
2021-05-23T06:53:34.104324620Z #########################
2021-05-23T06:53:34.109532296Z The following output is now a tail of the alert.log:
2021-05-23T06:53:34.111312511Z ORCLPDB1(3):ALTER DATABASE DEFAULT TABLESPACE "USERS"
2021-05-23T06:53:34.111345555Z ORCLPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
2021-05-23T06:53:34.111352142Z 2021-05-23T06:53:31.808184+00:00
2021-05-23T06:53:34.111354874Z ALTER SYSTEM SET control_files='/opt/oracle/oradata/ORCLCDB/control01.ctl' SCOPE=SPFILE;
2021-05-23T06:53:34.111357318Z 2021-05-23T06:53:31.815000+00:00
2021-05-23T06:53:34.111359588Z ALTER SYSTEM SET local_listener='' SCOPE=BOTH;
2021-05-23T06:53:34.111361866Z ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
2021-05-23T06:53:34.111364111Z Completed: ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
2021-05-23T06:53:34.111366445Z
2021-05-23T06:53:34.111368607Z XDB initialized.
5、连接数据库使用,尽情使用吧,开源免费的dbeaver工具
6、总结
当我们把镜像准备好,数据库的参数准备好,后续部署竟如此简单:
拉取镜像->编排镜像参数->启动镜像,大功告成
更多推荐
所有评论(0)