原 【DB宝12】在Docker中只需2步即可拥有Oracle 12cR2(12.2.0.1)企业版环境
Tags: Oracle原创LinuxDocker小麦苗环境搭建DB宝
一、从Docker Hub或阿里云镜像下载小麦苗上传的镜像文件
小麦苗的Docker Hub的地址:https://hub.docker.com/u/lhrbest
小麦苗的Oracle 12cR2(12.2.0.1)的Docker Hub地址:https://hub.docker.com/r/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1/tags
123456# 从Docker hub下载,网络不好时,一般比较慢docker pull lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:1.0# 推荐从阿里云下载docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:1.0# 从阿里云下载后可以tag成如下形式docker tag registry.cn-registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:1.0 lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:1.0镜像大概4.79G左右,解压后大约15G左右,所以请保留充足的空间。执行过程如下:
12345678910111213141516[root@lhrdocker ~]# docker search 12cR2 --no-truncNAME DESCRIPTION STARS OFFICIAL AUTOMATEDlhrbest/oracle_12cr2_ee_lhr_12.2.0.1 Oracle 12cR2 企业版, 12.2.0.1 ,QQ:646634621,微信公众号:DB宝,CentOS 7.6,包含一个cdb,sid为lhrcdb1,一个非cdb,sid为lhrsdb 0[root@lhrdocker ~]# docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:1.01.0: Pulling from lhrbest/oracle_12cr2_ee_lhr_12.2.0.1ac9208207ada: Already exists3f87d8dbb1ef: Already exists512a15c4c83e: Already existsce417a4cad38: Pull completeDigest: sha256:5b2924030665688c2dbd5722b0bf21fbf4fcc69efbac8f113dd43c43b6241341Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:1.0registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:1.0[root@lhrdocker ~]# docker tag registry.cn-registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:1.0 lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:1.0[root@lhrdocker ~]# docker images | grep 12.2lhrbest/oracle_12cr2_ee_lhr_12.2.0.1 1.0 c9a76e991b46 27 hours ago 14.8GBregistry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1 1.0 c9a76e991b46 27 hours ago 14.8GB
二、创建容器并启动数据库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # 创建镜像 docker run -itd --name lhrora1221 -h lhrora1221 --privileged=true -p 1521:1521 -p 222:22 -p 5500:5500 -p 5501:5501 lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:1.0 init # 进入容器 docker exec -it lhrora1221 bash # 启动数据库和监听 su - oracle lsnrctl start sqlplus / as sysdba startup exit ORACLE_SID=lhrsdb sas startup |
运行过程:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | [root@lhrdocker ~]# docker run -itd --name lhrora1221 -h lhrora1221 --privileged=true -p 1521:1521 -p 222:22 -p 5500:5500 -p 5501:5501 lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:1.0 init e46fc8ff1a9bb4dd905d08de3515036695a8267a2e0f30b553d05dc16f38005e [root@lhrdocker ~]# docker exec -it lhrora1221 bash [root@lhrora1221 /]# su - oracle Last login: Fri Jul 10 16:36:50 CST 2020 on pts/0 [oracle@lhrora1221 ~]$ lsnrctl start LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 11-JUL-2020 20:00:05 Copyright (c) 1991, 2016, Oracle. All rights reserved. Starting /u01/app/oracle/product/12.2.0.1/dbhome_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 12.2.0.1.0 - Production System parameter file is /u01/app/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora Log messages written to /u01/app/oracle/diag/tnslsnr/lhrora1221/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhrora1221)(PORT=1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=lhrora1221)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production Start Date 11-JUL-2020 20:00:05 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/lhrora1221/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhrora1221)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) The listener supports no services The command completed successfully [oracle@lhrora1221 ~]$ sas SQL*Plus: Release 12.2.0.1.0 Production on Sat Jul 11 20:00:17 2020 Copyright (c) 1982, 2016, Oracle. All rights reserved. Connected to an idle instance. SYS@lhrcdb1> startup ORACLE instance started. Total System Global Area 805306368 bytes Fixed Size 8797928 bytes Variable Size 583008536 bytes Database Buffers 205520896 bytes Redo Buffers 7979008 bytes Database mounted. Database opened. SYS@lhrcdb1> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 LHRPDB1 MOUNTED SYS@lhrcdb1> alter pluggable database lhrpdb1 open; Pluggable database altered. SYS@lhrcdb1> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 LHRPDB1 READ WRITE NO SYS@lhrcdb1> alter pluggable database all save state; Pluggable database altered. SYS@lhrcdb1> exit Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production [oracle@lhrora1221 ~]$ ORACLE_SID=lhrsdb [oracle@lhrora1221 ~]$ sas SQL*Plus: Release 12.2.0.1.0 Production on Sat Jul 11 20:02:10 2020 Copyright (c) 1982, 2016, Oracle. All rights reserved. Connected to an idle instance. SYS@lhrsdb> startup ORACLE instance started. Total System Global Area 805306368 bytes Fixed Size 8625856 bytes Variable Size 578814272 bytes Database Buffers 209715200 bytes Redo Buffers 8151040 bytes Database mounted. Database opened. SYS@lhrsdb> |
三、尽情使用吧
3.1 数据库使用
该镜像包括一个cdb(sid为lhrcdb1)和一个非cdb(sid为lhrsdb),可以直接使用:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | [oracle@lhrora1221 ~]$ lsnrctl status LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 11-JUL-2020 20:06:02 Copyright (c) 1991, 2016, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=lhrora1221)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production Start Date 11-JUL-2020 20:00:05 Uptime 0 days 0 hr. 5 min. 57 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/lhrora1221/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhrora1221)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=lhrora1221)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/lhrcdb1/xdb_wallet))(Presentation=HTTP)(Session=RAW)) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=lhrora1221)(PORT=5501))(Security=(my_wallet_directory=/u01/app/oracle/admin/lhrsdb/xdb_wallet))(Presentation=HTTP)(Session=RAW)) Services Summary... Service "aa133779e7bf28e8e053090011ac3234" has 1 instance(s). Instance "lhrcdb1", status READY, has 1 handler(s) for this service... Service "lhrcdb1" has 1 instance(s). Instance "lhrcdb1", status READY, has 1 handler(s) for this service... Service "lhrcdb1XDB" has 1 instance(s). Instance "lhrcdb1", status READY, has 1 handler(s) for this service... Service "lhrpdb1" has 1 instance(s). Instance "lhrcdb1", status READY, has 1 handler(s) for this service... Service "lhrsdb" has 1 instance(s). Instance "lhrsdb", status READY, has 1 handler(s) for this service... Service "lhrsdbXDB" has 1 instance(s). Instance "lhrsdb", status READY, has 1 handler(s) for this service... The command completed successfully |