ufrrumy65u1zb1 发表于 2022-12-15 18:05:50

实用教程--docker一键部署oracle19c

概述

之前都是用docker去实现一键部署mysql,oracle麻烦很多,dockerfile很不好写,有很多逻辑需要考虑,无意中看到一位大佬marcelo-ochoa的dockerfile,测试了下确实可行,这里分享下给大家。
<hr>
环境配置

操作系统:ubuntu16.04 TLS

docker Version: 18.09.2

oracle Version: 19.2.0.0.0

1、下载dockerfile

cd /optgit clone https://github.com/frobes/dba_devops.git
https://p3-sign.toutiaoimg.com/pgc-image/d5befb5c63254020af00e82d1a534e78~tplv-tt-large.image?x-expires=1986461365&x-signature=XAFSbyDj9xsFBr%2BvbmLP3fIiN6I%3D

# lltotal 32drwxr-xr-x 2 root root 4096 Feb 22 08:12 11.2.0.2drwxr-xr-x 2 root root 4096 Feb 22 08:12 12.1.0.2drwxr-xr-x 2 root root 4096 Feb 22 08:12 12.2.0.1drwxr-xr-x 2 root root 4096 Feb 22 08:12 18.3.0drwxr-xr-x 2 root root 4096 Feb 22 08:12 18.4.0drwxr-xr-x 2 root root 4096 Feb 22 08:12 19.2.0-rwxr-xr-x 1 root root 5145 Feb 22 08:12 buildDockerImage.sh# pwd/opt/docker-images/OracleDatabase/SingleInstance/dockerfiles
可以看到是存在19.2.0的dockerfile的,同时检查其安装的安装包文件名
# lltotal 68-rwxr-xr-x 1 root root 1148 Feb 22 08:12 checkDBStatus.sh-rwxr-xr-x 1 root root 905 Feb 22 08:12 checkSpace.sh-rw-r--r-- 1 root root 49 Feb 22 08:12 Checksum.ee-rwxr-xr-x 1 root root 3012 Feb 22 08:12 createDB.sh-rw-r--r-- 1 root root 9204 Feb 22 08:12 dbca.rsp.tmpl-rw-r--r-- 1 root root 6878 Feb 22 08:12 db_inst.rsp-rw-r--r-- 1 root root 3405 Feb 22 08:12 Dockerfile-rwxr-xr-x 1 root root 2526 Feb 22 08:12 installDBBinaries.sh-rwxr-xr-x 1 root root 6526 Feb 22 08:12 runOracle.sh-rwxr-xr-x 1 root root 1015 Feb 22 08:12 runUserScripts.sh-rwxr-xr-x 1 root root 758 Feb 22 08:12 setPassword.sh-rwxr-xr-x 1 root root 932 Feb 22 08:12 setupLinuxEnv.sh-rwxr-xr-x 1 root root 678 Feb 22 08:12 startDB.sh# cat Dockerfile |grep INSTALL_FILE_1 INSTALL_FILE_1="V981623-01.zip" \COPY --chown=oracle:dba $INSTALL_FILE_1 $INSTALL_RSP $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/
这里可以看到,安装包是叫V981623-01.zip
<hr>
2、制作镜像

2.1、拷贝19c安装包后生成镜像

将安装包V981623-01.zip拷贝到该目录下,运行开始安装

cd /opt/docker-images/OracleDatabase/SingleInstance/dockerfiles

./buildDockerImage.sh -v 19.2.0 -e

https://p3-sign.toutiaoimg.com/pgc-image/ade8f40f896643839b6956bb30ac40ae~tplv-tt-large.image?x-expires=1986461365&x-signature=toN8yw0qOAKCxCmvDbf4oJOJenY%3D

2.2、生成镜像过程:

https://p3-sign.toutiaoimg.com/pgc-image/205f213eed124387ab91147d079c8909~tplv-tt-large.image?x-expires=1986461365&x-signature=Cb87DTJw3mIeoyagle81j9%2B%2B%2Fx0%3D


https://p3-sign.toutiaoimg.com/pgc-image/9fbb2c82b27b49d0860b7f6fb82c9110~tplv-tt-large.image?x-expires=1986461365&x-signature=Ebs46QCyZUC00ahD9PoyE0yx8Ds%3D

2.3、安装完成:

https://p3-sign.toutiaoimg.com/pgc-image/2676fddd3fc24e5fabf8473d921108bc~tplv-tt-large.image?x-expires=1986461365&x-signature=KmZkbcANkpT%2F1PueNc0kxkkPaX8%3D

2.4、查看镜像:

docker images

https://p3-sign.toutiaoimg.com/pgc-image/8cb2f254f6c648dd9036505fbd609ecd~tplv-tt-large.image?x-expires=1986461365&x-signature=WBueFNVFuRRSSK%2Fm%2FfR%2FMhOqrsE%3D

到上面一步我们的镜像就做好了,下面基本都没什么太大问题。
<hr>
3、初始化数据库实例

3.1、初始化实例
#docker run --name oracle19c -p 1521:1521 -p 5500:5500 -v /oradata/oracle19c:/opt/oracle/oradata oracle/database:19.2.0-ee
https://p3-sign.toutiaoimg.com/pgc-image/4bd23f0936c34e44ab2eb9909ab63f5a~tplv-tt-large.image?x-expires=1986461365&x-signature=vCWAdN9msTcUyjdkVo60LjhIL9g%3D


https://p3-sign.toutiaoimg.com/pgc-image/9bb34ee79d504c3384fa74ab2ca9f82f~tplv-tt-large.image?x-expires=1986461365&x-signature=7eVsDRmfxBsL5Il2PL%2B%2BnIpa%2FF0%3D


https://p3-sign.toutiaoimg.com/pgc-image/b9689a90bfb74342bc1ffd508b457505~tplv-tt-large.image?x-expires=1986461365&x-signature=ceN%2BomU7fs1ajXEY4OYmgTQ2kBA%3D

注,如果“DATABASE IS READY TO USE!”字样已经出现,且后面的log一直停着不动,可以在别的窗口查看container。

3.2、查看容器

docker ps -a

https://p3-sign.toutiaoimg.com/pgc-image/703a5674ac1e4318b6fa5946f1222fb3~tplv-tt-large.image?x-expires=1986461365&x-signature=Kf6B6by%2Fdu5Qo6ENYfqqyQDBzHk%3D

3.3、检查数据文件

ll /oradata/oracle19c/ORCLCDB

https://p3-sign.toutiaoimg.com/pgc-image/aeac0ac73d7440e6a45a79454b5c8b86~tplv-tt-large.image?x-expires=1986461365&x-signature=U6LbZYY6ErGb5eUDDV8vfGAhE%2Fw%3D

4、登录主机或者数据库操作

docker ps -a

docker exec -it abe5 /bin/bash

sqlplus sys/1RmJBpJIsmU=1@ORCLCDB as sysdba

SQL> select instance_name,status from v$instance;

https://p3-sign.toutiaoimg.com/pgc-image/492cd2e8e40846c5a4e196ebeb7a075b~tplv-tt-large.image?x-expires=1986461365&x-signature=VUEqNGLXd0Nr13X8aLkRr6tq7VI%3D

到这里我们的数据库19c就部署好了。
<hr>
https://p3-sign.toutiaoimg.com/pgc-image/5a32fb1f0aa749b6ab5c47e57c4d9f36~tplv-tt-large.image?x-expires=1986461365&x-signature=1dKt23aVWOUQM5MlX3SI8QgPwSY%3D

前面核心命令就两句:

./buildDockerImage.sh -v 19.2.0 -e

docker run --name oracle19c -p 1521:1521 -p 5500:5500 -v /oradata/oracle19c:/opt/oracle/oradata oracle/database:19.2.0-ee

一直以来都想试着写个dockerfile来一键部署oracle,虽然对于oracle意义可能不是很大,今天参考一下其他大佬的dockerfile后自己修改做了一下,过程还是挺简单的,大家有兴趣也可以研究下dockerfile里面内容。

https://p3-sign.toutiaoimg.com/pgc-image/4906258bc44d4936b920ea0fcc14438d~tplv-tt-large.image?x-expires=1986461365&x-signature=HL1XuncCDJYPprfBLI4FlLyripo%3D

uppi20aaehurhu 发表于 2022-12-15 18:06:42

转发了

uq4tyrrst2wsjj 发表于 2022-12-15 18:06:54

转发了

ukglgo9lg0dza3 发表于 2022-12-15 18:07:05

转发了

uitsr8l8kxzhss 发表于 2022-12-15 18:07:21

转发了

uwqy8yz8fmdowb 发表于 2022-12-15 18:07:39

转发了

uh9g959ctiojzw 发表于 2022-12-15 18:08:27

转发了

俎佃霞 发表于 2022-12-15 18:09:14

转发了

uk004a6009ac91 发表于 2022-12-15 18:09:28

转发了

urpg1rb38lt4l3 发表于 2022-12-15 18:09:47

转发了
页: [1] 2
查看完整版本: 实用教程--docker一键部署oracle19c