1. 介质准备
1.1. 下载Oracle docker build file
近期Oracle 官方发布了19.3 版本的docke-images 构建程序,可在这里下载:可到github下载docker-images-master.zip
image.png
将下好的docker-images-master.zip 解压放在 /Users/myz/Docker/ 目录下:
cd /Users/myz/Docker/docker-images-master/OracleDatabase/SingleInstance/dockerfiles/19.3.0/
1.2. 下载Oracle19c 预安装程序
手动下载oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm ,同样放在19.3.0/ 目录下
下载地址:
1.3. 准备Oracle19c的安装程序
下载19C安装介质(可从官网) LINUX.X64_193000_db_home.zip同样放在19.3.0/ 目录下
其他可根据需要 把常用的安装包也放到这个位置 下, 如我常用 rlwrap-0.42-1.el6.x86_64.rpm
2. 配置 Oracle image
2.1. 修改Dockerfile
使用自带的oraclelinux:7-slim 及用官网介绍的方法遇到一些问题不好解决. 后来换成我常用的基础镜像centos:7.6.1810 加Oracle预安装文件oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm最后成功构建 .
vi Dockerfile
#FROM oraclelinux:7-slim as base
FROM centos:7.6.1810 as base
....
# Copy files needed during both installation and runtime
# -------------
COPY $SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DIR/
COPY oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm $INSTALL_DIR/
COPY rlwrap-0.42-1.el6.x86_64.rpm $INSTALL_DIR/
COPY $RUN_FILE $START_FILE $CREATE_DB_FILE $CONFIG_RSP $PWD_FILE $CHECK_DB_FILE $USER_SCRIPTS_FILE $ORACLE_BASE/
....
2.2. 修改setupLinuxEnv.sh
使用本地安装preinstall 包, 及增加些其他常用工具包;
vi setupLinuxEnv.sh
…
chmod ug+x $ORACLE_BASE/*.sh && \
#yum -y install oracle-database-preinstall-19c openssl && \
yum -y localinstall /opt/install/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm \
&& yum -y install openssl \
&& yum -y install openssl-devel \
&& yum -y install lsof \
&& yum -y install iproute \
&& yum -y install net-tools \
&& yum -y install rsyslog \
&& yum -y install bash-completion \
&& yum -y install tmux \
&& yum -y install lrzsz \
&& yum -y install telnet \
&& yum -y localinstall /opt/install/rlwrap-0.42-1.el6.x86_64.rpm && \
rm -rf /var/cache/yum && \
ln -s $ORACLE_BASE/$PWD_FILE /home/oracle/ && \
echo oracle:welcome1 | chpasswd && \
echo root:welcome1 | chpasswd && \
chown -R oracle:dba $ORACLE_BASE
2.3. 修改installDBBinaries.sh 文件
vi installDBBinaries.sh
…
# Temp location
#rm -rf /tmp/* && \
…
这里需要注释掉 rm /tmp/* 动作, 不然会报如下错误:
rm: cannot remove '/tmp/ks-script-6pKh_p': Operation not permitted
rm: cannot remove '/tmp/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm': Operation not permitted
rm: cannot remove '/tmp/yum.log': Operation not permitted
Removing intermediate container 508f7c0f5041
The command '/bin/sh -c chmod ug+x $INSTALL_DIR/*.sh && sync && $INSTALL_DIR/$INSTALL_DB_BINARIES_FILE $DB_EDITION' returned a non-zero code: 1
ERROR: Oracle Database Docker Image was NOT successfully created.
ERROR: Check the output and correct any reported problems with the docker build operation.
2.4 .其它视需要
默认数据库 CDB模式, 数据库名 ORCLCDB, PDB name 为 ORCLDPB1 (可在run时指定)
其他可视需要修改 createDB.sh 及runOracle.sh
3. 构建 Oracle镜像
Dockfile所在上一级目录下下执行build
./buildDockerImage.sh -v 19.3.0 -e
cd /Users/myz/Docker/docker-images-master/OracleDatabase/SingleInstance/dockerfiles/
./buildDockerImage.sh -v 19.3.0 -e
....
Removing intermediate container 4a78c5c0bca1
---> 7a679ae24618
Step 25/25 : CMD exec $ORACLE_BASE/$RUN_FILE
---> Running in 2bb5ef7ec74c
Removing intermediate container 2bb5ef7ec74c
---> 3c1a9d1ffc0a
Successfully built 3c1a9d1ffc0a
Successfully tagged oracle/database:19.3.0-ee
Oracle Database Docker Image for 'ee' version 19.3.0 is ready to be extended:
--> oracle/database:19.3.0-ee
Build completed in 653 seconds.
myzmac:dockerfiles myz$
myzmac:dockerfiles myz$
大概10分钟左右成功完成镜像制作
如果过程中报错,需要仔细查看报错文件及内容进行排错;
myzmac:dockerfiles myz$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
oracle/database 19.3.0-ee 3c1a9d1ffc0a 6 minutes ago 6.61GB
接下来就可以通过该镜像来安装部署Oracle19c实例....
网友评论