原 【DB宝13】在Docker中只需2步即可拥有Oracle 12cR1(12.1.0.2)企业版环境
Tags: Oracle原创LinuxDocker安装部署小麦苗环境搭建快速体验体验DB宝
一、从Docker Hub或阿里云镜像下载小麦苗上传的镜像文件
小麦苗的Docker Hub的地址:https://hub.docker.com/u/lhrbest
小麦苗的Oracle 12cR1(12.1.0.2)的Docker Hub地址:https://hub.docker.com/r/lhrbest/oracle_12cr1_ee_lhr_12.1.0.2/tags
12345# 从Docker hub下载,网络不好时,一般比较慢docker pull lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:1.0# 推荐从阿里云下载docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:1.0
从阿里云下载后可以tag成如下形式
docker tag registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:1.0 lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:1.0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 镜像大概4.05G左右,解压后大约16G左右,所以请保留充足的空间。执行过程如下: ```sql [root@lhrdocker ~]# docker search 12cR1 --no-trunc NAME DESCRIPTION STARS OFFICIAL AUTOMATED lhrbest/oracle_12cr1_ee_lhr_12.1.0.2 Oracle 12cR1 企业版, 12.1.0.2 ,QQ:646634621,微信公众号:DB宝,CentOS 7.6,包含一个cdb,sid为lhrcdb1,一个非cdb,sid为lhrsdb 0 [root@lhrdocker ~]# [root@lhrdocker ~]# docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:1.0 1.0: Pulling from lhrbest/oracle_12cr1_ee_lhr_12.1.0.2 ac9208207ada: Already exists 3f87d8dbb1ef: Pull complete 512a15c4c83e: Pull complete 0602305ad716: Pull complete Digest: sha256:99ef263a861f71c7bac56018fad58b61640e40a44e98f0e9bd135a077a07960e Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:1.0 registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:1.0 [root@lhrdocker ~]# docker tag registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:1.0 lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:1.0 [root@lhrdocker ~]# docker images | grep 12.1 lhrbest/oracle_12cr1_ee_lhr_12.1.0.2 1.0 2d8e7a9451ec 28 hours ago 15.9GB registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr1_ee_lhr_12.1.0.2 1.0 2d8e7a9451ec 28 hours ago 15.9GB |
二、创建容器并启动数据库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # 创建镜像 docker run -itd --name lhrora1212 -h lhrora1212 --privileged=true -p 1522:1521 -p 223:22 -p 5550:5500 -p 5551:5501 lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:1.0 init # 进入容器 docker exec -it lhrora1212 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 | [root@lhrdocker ~]# docker run -itd --name lhrora1212 -h lhrora1212 --privileged=true -p 1522:1521 -p 223:22 -p 5550:5500 -p 5551:5501 lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:1.0 init b9896808a05e6d755d67e4c35159a39ab538fb6dde2af50c5e4a45a01b50b0cc [root@lhrdocker ~]# docker exec -it lhrora1212 bash [root@lhrora1212 /]# su - oracle Last login: Fri Jul 10 18:15:13 CST 2020 on pts/2 [oracle@lhrora1212 ~]$ lsnrctl start LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 11-JUL-2020 22:52:39 Copyright (c) 1991, 2014, Oracle. All rights reserved. Starting /u01/app/oracle/product/12.1.0.2/dbhome_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 12.1.0.2.0 - Production System parameter file is /u01/app/oracle/product/12.1.0.2/dbhome_1/network/admin/listener.ora Log messages written to /u01/app/oracle/diag/tnslsnr/lhrora1212/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhrora1212)(PORT=1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=lhrora1212)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production Start Date 11-JUL-2020 22:52:39 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.1.0.2/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/lhrora1212/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhrora1212)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) The listener supports no services The command completed successfully [oracle@lhrora1212 ~]$ sas SQL*Plus: Release 12.1.0.2.0 Production on Sat Jul 11 22:52:42 2020 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to an idle instance. SYS@lhrcdb1> startup ORACLE instance started. Total System Global Area 805306368 bytes Fixed Size 2929552 bytes Variable Size 377490544 bytes Database Buffers 419430400 bytes Redo Buffers 5455872 bytes Database mounted. Database opened. SYS@lhrcdb1> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 LHRPDB1 READ WRITE NO SYS@lhrcdb1> exit Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options [oracle@lhrora1212 ~]$ ORACLE_SID=lhrsdb [oracle@lhrora1212 ~]$ sas SQL*Plus: Release 12.1.0.2.0 Production on Sat Jul 11 22:53:51 2020 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to an idle instance. SYS@lhrsdb> startup ORACLE instance started. Total System Global Area 805306368 bytes Fixed Size 2929552 bytes Variable Size 373296240 bytes Database Buffers 423624704 bytes Redo Buffers 5455872 bytes Database mounted. Database opened. SYS@lhrsdb> show pdbs SYS@lhrsdb> exit Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options |
三、尽情使用吧
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 | [oracle@lhrora1212 ~]$ lsnrctl status LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 11-JUL-2020 22:56:29 Copyright (c) 1991, 2014, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=lhrora1212)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production Start Date 11-JUL-2020 22:52:39 Uptime 0 days 0 hr. 3 min. 49 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/12.1.0.2/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/lhrora1212/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhrora1212)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=lhrora1212)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/lhrcdb1/xdb_wallet))(Presentation=HTTP)(Session=RAW)) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=lhrora1212)(PORT=5501))(Security=(my_wallet_directory=/u01/app/oracle/admin/lhrsdb/xdb_wallet))(Presentation=HTTP)(Session=RAW)) Services Summary... 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 |
3.2 创建数据库
我们也可以自己创建自己需要的数据库,如下所示: