, , ,

部署Oracle数据库到Docker

计划把公司应用后台的数据库服务也统一迁移到docker上,因此起了在docker上部署Oracle数据库的念头。记得以前在docker hub上看到过现成的数据库image,上去一搜,发现不是版本太低就是说被O记要求删除。既然是这样,那O记官方有没以支持呢?放狗一搜,发现O记官方在github上有专门的docker images项目,包含了Java、数据库、应用等等的镜像生成文件。就算是自己生成镜像文件,这些资料也对写Dockerfile很有参考价值。

在github上下载Oracle数据库的docker文件,在OTN下载好Oracle Database 12C的安装包,把zip文件置于OracleDatabase/dockerfiles/12.0.0.2目录下,然后开始Oracle数据库docker的无脑安装 。

1.运行dockerfiles下的buildDockerImage.sh命令

从Oracle Linux的slim-7版本生成数据库镜像文件,该命令支持生成Oracle数据库企业版、标准版和XE版本。俺使用的是企业版。


# ./buildDockerImage.sh -v 12.1.0.2 -e -i

该脚本命令参数说明如下:

-v: version to build
Choose one of: 11.2.0.2 12.1.0.2
-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

开始配置环境,复制安装文件,静默安装数据库,最后生成镜像。大概需要10来分钟时间。

[highlight dark=”no”]注:在生成数据库镜像前,请特别留意Docker的存储驱动配置必须btrfs或overlay2,如果使用aufs在生成过程中会出现各种问题,俺还特意在github上特意开了issue讨论这个问题。[/highlight]

2.在docker容器中运行Oracle数据库


docker run --name \
-p :1521 -p :5500 \
-e ORACLE_SID= \
-e ORACLE_PDB= \
-e ORACLE_CHARACTERSET= \
-v [:]/opt/oracle/oradata \
oracle/database:12.1.0.2-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_CHARACTERSET:
The character set to use when creating the database (default: AL32UTF8)
-v The data volume to use for the database.
Has to be owned by the Unix user “oracle” or set appropriately.
If omitted the database will not be persisted over container recreation.

0 回复

发表评论

Want to join the discussion?
Feel free to contribute!

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注