原 【DB宝11】在Docker中只需2步即可拥有Oracle 11g企业版环境(11.2.0.3)
Tags: Oracle原创LinuxDocker安装部署小麦苗环境搭建快速体验体验
一、从Docker Hub或阿里云镜像下载小麦苗上传的镜像文件
- 小麦苗的Docker Hub的地址:https://hub.docker.com/u/lhrbest
- Oracle 11g DB的地址:https://hub.docker.com/repository/docker/lhrbest/oracle_11g_ee_lhr_11.2.0.3/tags?page=1
1 2 3 4 5 6 | # 从Docker hub下载,网络不好时,一般比较慢 docker pull lhrbest/oracle_11g_ee_lhr_11.2.0.3:1.0 # 可以选择从阿里云下载 docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_11g_ee_lhr_11.2.0.3:1.0 # 从阿里云下载后可以tag成如下形式 docker tag registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_11g_ee_lhr_11.2.0.3:1.0 lhrbest/oracle_11g_ee_lhr_11.2.0.3:1.0 |
镜像大概2.75G左右,解压后大约7G左右,所以请保留充足的空间。执行过程如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | [root@docker36 ~]# docker search 11.2.0.3 NAME DESCRIPTION STARS OFFICIAL AUTOMATED lhrbest/oracle_11g_ee_lhr_11.2.0.3 Oracle 11g 企业版, 11.2.0.3 ,QQ:646634621… 1 [root@docker36 ~]# [root@docker36 ~]# docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_11g_ee_lhr_11.2.0.3:1.0 1.0: Pulling from lhrbest/oracle_11g_ee_lhr_11.2.0.3 5dd797628260: Pull complete 72716ec4f779: Pull complete Digest: sha256:95b663e35ab7a21581d6a0c2d15b18a98c1ac484cd2621778f744ef0e6d61394 Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_11g_ee_lhr_11.2.0.3:1.0 registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_11g_ee_lhr_11.2.0.3:1.0 [root@docker36 ~]# docker tag registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_11g_ee_lhr_11.2.0.3:1.0 lhrbest/oracle_11g_ee_lhr_11.2.0.3:1.0 [root@docker36 ~]# docker images | grep 11g lhrbest/oracle_11g_ee_lhr_11.2.0.3 1.0 ac837aaa3923 2 hours ago 7.07GB registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_11g_ee_lhr_11.2.0.3 1.0 ac837aaa3923 2 hours ago 7.07GB |
二、创建容器并启动数据库
1 2 3 4 5 6 7 8 9 10 11 12 | # 创建容器 docker run -itd --name lhrora11203 -h lhrora11203 --privileged=true -p 1521:1521 -p 222:22 -p 1158:1158 lhrbest/oracle_11g_ee_lhr_11.2.0.3:1.0 init # 进入容器 docker exec -it lhrora11203 bash # 启动数据库和监听 su - oracle lsnrctl start sqlplus / as sysdba 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 | [root@docker36 ~]# docker run -itd --name lhrora11203 -h lhrora11203 --privileged=true -p 1521:1521 -p 222:22 -p 1158:1158 lhrbest/oracle_11g_ee_lhr_11.2.0.3:1.0 init 9700334260ec78f9152fc961fba75e5db0b0909afa250e33fc8215e04b5a00fa [root@docker36 ~]# docker exec -it lhrora11203 bash [root@localhost /]# su - oracle [oracle@lhrora11203 ~]$ lsnrctl start LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 10-JUL-2020 08:51:13 Copyright (c) 1991, 2011, Oracle. All rights reserved. Starting /u01/app/oracle/product/11.2.0.3/dbhome_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 11.2.0.3.0 - Production System parameter file is /u01/app/oracle/product/11.2.0.3/dbhome_1/network/admin/listener.ora Log messages written to /u01/app/oracle/diag/tnslsnr/lhrora11203/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhrora11203)(PORT=1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 10-JUL-2020 08:51:13 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/11.2.0.3/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/lhrora11203/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhrora11203)(PORT=1521))) The listener supports no services The command completed successfully [oracle@lhrora11203 ~]$ sas SQL*Plus: Release 11.2.0.3.0 Production on Fri Jul 10 08:51:19 2020 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to an idle instance. SYS@LHR11G> startup ORACLE instance started. Total System Global Area 325685248 bytes Fixed Size 2228064 bytes Variable Size 121634976 bytes Database Buffers 197132288 bytes Redo Buffers 4689920 bytes Database mounted. Database opened. SYS@LHR11G> |
三、尽情使用吧
3.1 数据库使用
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 | [oracle@lhrora11203 ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 10-JUL-2020 08:55:02 Copyright (c) 1991, 2011, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production Start Date 10-JUL-2020 08:51:13 Uptime 0 days 0 hr. 3 min. 48 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/11.2.0.3/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/lhrora11203/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhrora11203)(PORT=1521))) Services Summary... Service "LHR11G" has 1 instance(s). Instance "LHR11G", status READY, has 1 handler(s) for this service... Service "LHR11GXDB" has 1 instance(s). Instance "LHR11G", status READY, has 1 handler(s) for this service... The command completed successfully [oracle@lhrora11203 ~]$ sas SQL*Plus: Release 11.2.0.3.0 Production on Fri Jul 10 08:54:30 2020 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SYS@LHR11G> select * from v$version; BANNER ---------------------------------------------------------------------------------------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for Linux: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production |
3.2 创建数据库(可选)
我们也可以自己创建自己需要的数据库,如下所示,
1 2 3 4 5 6 7 8 9 10 11 | dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \ -gdbname LHR11G2 -sid LHR11G2 \ -sysPassword lhr -systemPassword lhr \ -datafileDestination '/u01/app/oracle/oradata' \ -recoveryAreaDestination '/u01/app/oracle/flash_recovery_area' \ -storageType FS \ -characterset AL32UTF8 -nationalCharacterSet AL16UTF16 \ -sampleSchema true \ -totalMemory 300 \ -databaseType OLTP \ -emConfiguration NONE |
3.3 EMDC的使用
该镜像没有创建EMDC(Enterprise Manager Database Control),需要我们手动来创建,主要命令如下所示:
1 2 3 4 5 6 7 8 | # 1、解锁dbsnmp用户 alter user dbsnmp identified by lhr account unlock; # 2、创建EMDC emca -config dbcontrol db -repos recreate # 查看状态 emctl status dbconsole # 3、浏览器访问EM 192.168.1.36:1158/em |
不错哈