基于docker怎么部署Oracle 19c
短信预约 -IT技能 免费直播动态提醒
本文小编为大家详细介绍“基于docker怎么部署Oracle 19c”,内容详细,步骤清晰,细节处理妥当,希望这篇“基于docker怎么部署Oracle 19c”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。
一. 拉取Oracle 19c镜像
[root@node08002 docker]# docker pull registry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle:19c19c: Pulling from zhuyijun/oraclebce8f778fef0: Pull complete 3fc3fd32c0bc: Pull complete 02948dd6d654: Pull complete 67f2dfeb2f1b: Pull complete 2e42d8039fd9: Pull complete b94f01bb60c6: Pull complete Digest: sha256:3898a9394720f30ce7f0b83ef2d172f4cd11b958282e0505f83cf2b0e5eaf7d4Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle:19cregistry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle:19c
二. 查看镜像
[root@node08002 docker]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEregistry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle 19c 7b5eb4597688 20 months ago 6.61GB[root@node08002 docker]#
三. 创建Oracle 19c镜像的容器
3.1创建目录
[root@node08002 docker]# mkdir /opt/oradata[root@node08002 docker]# chmod -R 777 /opt/oradata/[root@node08002 docker]#
3.2 创建实例
[root@node08002 docker]# docker run -d -it --name oracle19c -p 1521:1521 -p 5500:5500 -v /opt/oradata:/opt/oracle/oradata registry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle:19c
3.3 查看日志
[root@node08002 ~]# docker logs -f oracle19cORACLE EDITION: ENTERPRISEORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: CRiP1dWzDHA=1 LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 06-APR-2022 10:28:18Copyright (c) 1991, 2019, Oracle. All rights reserved.Starting /opt/oracle/product/19c/dbhome_1/bin/tnslsnr: please wait...TNSLSNR for Linux: Version 19.0.0.0.0 - ProductionSystem parameter file is /opt/oracle/product/19c/dbhome_1/network/admin/listener.oraLog messages written to /opt/oracle/diag/tnslsnr/1249a4a7bb32/listener/alert/log.xmlListening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 19.0.0.0.0 - ProductionStart Date 06-APR-2022 10:28:18Uptime 0 days 0 hr. 0 min. 0 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /opt/oracle/product/19c/dbhome_1/network/admin/listener.oraListener Log File /opt/oracle/diag/tnslsnr/1249a4a7bb32/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))The listener supports no servicesThe command completed successfullyPrepare for db operation8% completeCopying database files31% completeCreating and starting Oracle instance32% complete36% complete40% complete43% complete46% completeCompleting Database Creation51% complete54% completeCreating Pluggable Databases58% complete77% completeExecuting Post Configuration Actions100% completeDatabase creation complete. For details check the logfiles at: /opt/oracle/cfgtoollogs/dbca/ORCLCDB.Database Information:Global Database Name:ORCLCDBSystem Identifier(SID):ORCLCDBLook at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.SQL*Plus: Release 19.0.0.0.0 - Production on Wed Apr 6 10:48:37 2022Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle. All rights reserved.
四、 修改密码
系统默认的system密码修改成oracle
[root@node08002 ~]# docker exec oracle19c ./setPassword.sh oracle
setPassword.sh 脚本如下
[root@node08002 ~]# docker exec -it oracle19c /bin/bash[oracle@1249a4a7bb32 ~]$ lssetPassword.sh[oracle@1249a4a7bb32 ~]$ pwd/home/oracle[oracle@1249a4a7bb32 ~]$ cat setPassword.sh #!/bin/bash# LICENSE UPL 1.0## Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.# # Since: November, 2016# Author: gerald.venzl@oracle.com# Description: Sets the password for sys, system and pdb_admin## DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.# ORACLE_PWD=$1ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"ORACLE_PDB="`ls -dl $ORACLE_BASE/oradata/$ORACLE_SID/*/ | grep -v pdbseed | awk '{print $9}' | cut -d/ -f6`"ORAENV_ASK=NOsource oraenv sqlplus / as sysdba << EOF ALTER USER SYS IDENTIFIED BY "$ORACLE_PWD"; ALTER USER SYSTEM IDENTIFIED BY "$ORACLE_PWD"; ALTER SESSION SET CONTAINER=$ORACLE_PDB; ALTER USER PDBADMIN IDENTIFIED BY "$ORACLE_PWD"; exit;EOF [oracle@1249a4a7bb32 ~]$
五、连接数据库
sqlplus system/oracle@xxx.xxx.xxx.xxx:1521/ORCLCDB
5.1测试方案一:进入容器内部测试
[root@node08002 ~]# docker exec -it oracle19c /bin/bash[oracle@1249a4a7bb32 ~]$ sqlplus system/oracle@localhost:1521/ORCLCDB SQL*Plus: Release 19.0.0.0.0 - Production on Thu Apr 7 01:54:17 2022Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle. All rights reserved.Last Successful login time: Thu Apr 07 2022 01:53:14 +00:00Connected to:Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - ProductionSQL> Show user;USER is "SYSTEM"SQL> exitDisconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production[oracle@1249a4a7bb32 ~]$
5.2测试方案二:用navicat连接测试
[root@node08002 ~]# docker exec -it oracle19c /bin/bash[oracle@1249a4a7bb32 ~]$ cd /opt/oracle/product/19c/dbhome_1/network/admin/[oracle@1249a4a7bb32 admin]$ lslistener.ora samples shrept.lst sqlnet.ora tnsnames.ora[oracle@1249a4a7bb32 admin]$ vim sqlnet.ora [oracle@1249a4a7bb32 admin]$ cat sqlnet.ora NAME.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, HOSTNAME)[oracle@1249a4a7bb32 admin]$ vim sqlnet.ora [oracle@1249a4a7bb32 admin]$ cat sqlnet.ora NAME.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, HOSTNAME)SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8SQLNET.ALLOWED_LOGON_VERSION_SERVER=8[oracle@1249a4a7bb32 admin]$ exitexit[root@node08002 ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES1249a4a7bb32 registry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle:19c "/bin/sh -c 'exec $O…" 16 hours ago Up 16 hours (healthy) 0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:5500->5500/tcp, :::5500->5500/tcp oracle19c[root@node08002 ~]# docker restart oracle19coracle19c[root@node08002 ~]#
很奇怪,又要修改一次密码,具体操作步骤如下:
[root@node08002 ~]# docker exec -it oracle19c /bin/bash[oracle@1249a4a7bb32 ~]$ sqlplus system/oracle@localhost:1521/ORCLCDB SQL*Plus: Release 19.0.0.0.0 - Production on Thu Apr 7 02:59:52 2022Version 19.3.0.0.0 Copyright (c) 1982, 2019, Oracle. All rights reserved. Last Successful login time: Thu Apr 07 2022 02:59:10 +00:00 Connected to:Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - ProductionVersion 19.3.0.0.0 SQL> alter user system identified by oracle; User altered. SQL> exitDisconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - ProductionVersion 19.3.0.0.0
终于可以连接了
读到这里,这篇“基于docker怎么部署Oracle 19c”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注编程网行业资讯频道。
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341