在Docker中快速使用各个版本的Oracle数据库(10g、11g、12c、18c、19c、21c、23c)

 

镜像地址

为了测试需要,麦老师制作了各个版本的Oracle数据库环境,下载地址如下:

  1# oracle
  2nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle23cfree:1.0 &
  3nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle21c_ee_db_21.3.0.0 &
  4nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle19clhr_asm_db_12.2.0.3:2.0 &
  5nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle18clhr_rpm_db_12.2.0.2:2.0 &
  6nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:2.0 &
  7nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:2.0 &
  8nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_11g_ee_lhr_11.2.0.4:2.0 &
  9nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_11g_ee_lhr_11.2.0.3:2.0 &
 10nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_10g_ee_lhr_10.2.0.5:2.0 &
 11nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_10g_ee_lhr_10.2.0.1:2.0 &
 12
 13
 14# 23c免费开发者版本
 15docker run -itd --name lhroracle23c -h lhroel87 \
 16  -p 1530:1521 -p 38389:3389 \
 17  -v /sys/fs/cgroup:/sys/fs/cgroup \
 18  --privileged=true lhrbest/oracle23cfree:1.0 \
 19  /usr/sbin/init
 20
 21 docker exec -it lhroel87 bash
 22
 23
 24
 25# 21c 二进制安装
 26docker run -d --name lhroracle21c -h lhroracle21c \
 27  -p 5510:5500 -p 55100:5501 -p 1530:1521  -p 3400:3389 \
 28  -v /sys/fs/cgroup:/sys/fs/cgroup \
 29  --privileged=true lhrbest/oracle21c_ee_db_21.3.0.0 \
 30  /usr/sbin/init
 31
 32
 33
 34# 19c ASM
 35docker run -itd -h lhr2019ocpasm --name lhr2019ocpasm \
 36  -p 1555:1521 -p 5555:5500 -p 55550:5501 -p 555:22 -p 3400:3389 \
 37  --privileged=true \
 38  lhrbest/oracle19clhr_asm_db_12.2.0.3:2.0 init
 39
 40# 对于ASM,① ASM磁盘脚本:/etc/initASMDISK.sh,请确保脚本/etc/initASMDISK.sh中的内容都可以正常执行
 41# ② 需要在宿主机上安装以下软件
 42yum install -y kmod-oracleasm
 43wget https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracleasm-support-2.1.11-2.el7.x86_64.rpm
 44wget https://download.oracle.com/otn_software/asmlib/oracleasmlib-2.0.12-1.el7.x86_64.rpm
 45rpm -ivh *.rpm
 46
 47systemctl enable oracleasm.service
 48oracleasm init
 49oracleasm status
 50
 51
 52
 53# 19c rpm方式安装
 54docker run -itd -h lhrora19c --name lhrora19c  \
 55  -p 1529:1521 -p 5509:5500 -p 55090:5501 -p 229:22 -p 3399:3389 \
 56  --privileged=true \
 57  lhrbest/oracle19clhr_rpm_db_12.2.0.3:2.0 init
 58
 59# 18c rpm方式安装
 60docker run -itd -h lhrora18c --name lhrora18c \
 61  -p 1528:1521 -p 5508:5500 -p 55080:5501 -p 228:22 -p 3398:3389 \
 62  --privileged=true \
 63  lhrbest/oracle18clhr_rpm_db_12.2.0.2:2.0 init
 64
 65# 12.2.0.1 二进制安装
 66docker run -itd --name lhrora1221 -h lhrora1221 \
 67  -p 1526:1521 -p 5526:5500 -p 55260:5501 -p 226:22 -p 3396:3389 \
 68  --privileged=true \
 69  lhrbest/oracle_12cr2_ee_lhr_12.2.0.1:2.0 init
 70
 71# 12.1.0.2 二进制安装
 72docker run -itd --name lhrora1212 -h lhrora1212 \
 73  -p 1525:1521 -p 5525:5500 -p 55250:5501 -p 225:22 -p 3395:3389 \
 74  --privileged=true \
 75  lhrbest/oracle_12cr1_ee_lhr_12.1.0.2:2.0 init
 76
 77# 11.2.0.4 二进制安装
 78docker run -itd --name lhrora11204 -h lhrora11204 -p 3394:3389 \
 79  -p 1524:1521 -p 1124:1158 -p 224:22 \
 80  --privileged=true \
 81  lhrbest/oracle_11g_ee_lhr_11.2.0.4:2.0 init
 82
 83# 11.2.0.3 二进制安装
 84docker run -itd --name lhrora11203 -h lhrora11203 -p 3393:3389 \
 85  -p 1523:1521 -p 1123:1158 -p 223:22 \
 86  --privileged=true \
 87  lhrbest/oracle_11g_ee_lhr_11.2.0.3:2.0 init
 88
 89# 10.2.0.5 二进制安装,-h参数不能变
 90docker run -itd --name lhrora10205 -h lhrora10g -p 3380:3389 \
 91  -p 1512:1521  -p 212:22 \
 92  --privileged=true \
 93  lhrbest/oracle_10g_ee_lhr_10.2.0.5:2.0 init
 94
 95
 96# 10.2.0.1 二进制安装,-h参数不能变
 97docker run -itd --name lhrora10201 -h lhrora10g -p 3379:3389 \
 98  -p 1511:1521  -p 211:22 \
 99  --privileged=true \
100  lhrbest/oracle_10g_ee_lhr_10.2.0.1:2.0 init  

使用方法

之前也详细说明过一些镜像的使用方法,例如:11.2.0.

23c:

https://www.xmmup.com/zaidockerzhongkuaisutiyanoracle-23cmianfeikaifazheban.html

21c:

https://www.xmmup.com/dbbao76zaidockerzhongzhixu2bujikeyongyouoracle-21chuanjing.html

19c ASM:

https://www.xmmup.com/dbbao4zhixu2bujikeyongyouoracle19cdeasmdbhuanjing.html

https://www.xmmup.com/dbbao4zhixu2bujikeyongyouoracle19cdeasmdbhuanjing.html

【DB宝7】如何在Docker容器中一步一步安装配置Oracle19c的ASM+DB环境

【DB宝3】在Docker中使用rpm包的方式安装Oracle 19c

【DB宝4】只需2步即可拥有Oracle19c的ASM+DB环境

18c:

https://www.xmmup.com/dbbao10zaidockerzhongzhixu2bujikeyongyouoracle-18chuanjing.html

【DB宝10】在Docker中只需2步即可拥有Oracle18c环境

11g:

https://www.xmmup.com/dbbao14zaidockerzhongzhixu2bujikeyongyouoracle-11gqiyebanhuanjing11-2-0-4.html

https://www.xmmup.com/dbbao11zaidockerzhongzhixu2bujikeyongyouoracle-11gqiyebanhuanjing11-2-0-3.html

【DB宝11】在Docker中只需2步即可拥有Oracle 11g企业版环境(11.2.0.3)

【DB宝14】在Docker中只需2步即可拥有Oracle 11g企业版环境(11.2.0.4)

12.2.0.1:

https://www.xmmup.com/dbbao12zaidockerzhongzhixu2bujikeyongyouoracle-12cr212-2-0-1qiyebanhuanjing.html

【DB宝12】在Docker中只需2步即可拥有Oracle 12cR2(12.2.0.1)企业版环境

12.1.0.2:

https://www.xmmup.com/dbbao13zaidockerzhongzhixu2bujikeyongyouoracle-12cr112-1-0-2qiyebanhuanjing.html

【DB宝13】在Docker中只需2步即可拥有Oracle 12cR1(12.1.0.2)企业版环境

lhr10g =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.141)(PORT = 1512))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = lhr10g)
    )
  )
  
  
lhr11g =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.141)(PORT = 1524))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = lhr11g)
    )
  )


#system/oracle123 sys/lhr

[root@docker ~]# systemctl start docker
 
[root@docker ~]# docker images
REPOSITORY                                                             TAG       IMAGE ID       CREATED       SIZE
lhrbest/oracle_10g_ee_lhr_10.2.0.5                                     2.0       082a5a3fb810   2 years ago   7.02GB
registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_10g_ee_lhr_10.2.0.5   2.0       082a5a3fb810   2 years ago   7.02GB
lhrbest/oracle_11g_ee_lhr_11.2.0.4                                     2.0       fc7ad72a62c8   3 years ago   8.05GB
registry.cn-hangzhou.aliyuncs.com/lhrbest/oracle_11g_ee_lhr_11.2.0.4   2.0       fc7ad72a62c8   3 years ago   8.05GB

[root@docker ~]# docker ps -a
CONTAINER ID   IMAGE                                    COMMAND   CREATED          STATUS                        PORTS                                                                                                                                                                  NAMES
3dbd50a79952   lhrbest/oracle_11g_ee_lhr_11.2.0.4:2.0   "init"    35 minutes ago   Exited (255) 32 seconds ago   0.0.0.0:224->22/tcp, :::224->22/tcp, 0.0.0.0:1124->1158/tcp, :::1124->1158/tcp, 0.0.0.0:1524->1521/tcp, :::1524->1521/tcp, 0.0.0.0:3394->3389/tcp, :::3394->3389/tcp   lhrora11204
f38d1c1c33b9   lhrbest/oracle_10g_ee_lhr_10.2.0.5:2.0   "init"    38 minutes ago   Exited (255) 32 seconds ago   0.0.0.0:212->22/tcp, :::212->22/tcp, 0.0.0.0:1512->1521/tcp, :::1512->1521/tcp, 0.0.0.0:3380->3389/tcp, :::3380->3389/tcp                                              lhrora10205
 
[root@docker ~]# docker start lhrora11204
lhrora11204
[root@docker ~]# docker start lhrora10205
lhrora10205
[root@docker ~]# docker ps
CONTAINER ID   IMAGE                                    COMMAND   CREATED          STATUS          PORTS                                                                                                                                                                  NAMES
3dbd50a79952   lhrbest/oracle_11g_ee_lhr_11.2.0.4:2.0   "init"    36 minutes ago   Up 13 seconds   0.0.0.0:224->22/tcp, :::224->22/tcp, 0.0.0.0:1124->1158/tcp, :::1124->1158/tcp, 0.0.0.0:1524->1521/tcp, :::1524->1521/tcp, 0.0.0.0:3394->3389/tcp, :::3394->3389/tcp   lhrora11204
f38d1c1c33b9   lhrbest/oracle_10g_ee_lhr_10.2.0.5:2.0   "init"    39 minutes ago   Up 4 seconds    0.0.0.0:212->22/tcp, :::212->22/tcp, 0.0.0.0:1512->1521/tcp, :::1512->1521/tcp, 0.0.0.0:3380->3389/tcp, :::3380->3389/tcp                                              lhrora10205
 

[root@docker ~]# docker exec -it lhrora10205 bash
[root@lhrora10g /]# su - oracle
[oracle@lhrora10g ~]$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 01-SEP-2023 01:46:46

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/10.2.0.1/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Log messages written to /u01/app/oracle/product/10.2.0.1/dbhome_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhrora10g)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date                01-SEP-2023 01:46:46
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/product/10.2.0.1/dbhome_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhrora10g)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@lhrora10g ~]$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.5.0 - Production on Fri Sep 1 01:46:57 2023

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to an idle instance.

SYS@lhr10g> startup
ORACLE instance started.

Total System Global Area  209715200 bytes
Fixed Size            2095184 bytes
Variable Size          146802608 bytes
Database Buffers       54525952 bytes
Redo Buffers            6291456 bytes
Database mounted.
Database opened.
SYS@lhr10g> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@lhrora10g ~]$ exit
logout
[root@lhrora10g /]# exit
exit
[root@docker ~]# df -h
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs             7.1G     0  7.1G   0% /dev
tmpfs                7.1G     0  7.1G   0% /dev/shm
tmpfs                7.1G  8.9M  7.1G   1% /run
tmpfs                7.1G     0  7.1G   0% /sys/fs/cgroup
/dev/mapper/ol-root   27G   21G  6.5G  77% /
/dev/sda1           1014M  183M  832M  19% /boot
tmpfs                1.5G     0  1.5G   0% /run/user/0
overlay               27G   21G  6.5G  77% /var/lib/docker/overlay2/5a3a4c8a1286c9f7445b4830ada38f152b32619cf4751b3781e53439d168b706/merged
overlay               27G   21G  6.5G  77% /var/lib/docker/overlay2/fa5beb76373d7bdee1f55e869ef54c8a5a7b1b899e37f72b282c71a12a80b197/merged


[root@docker ~]# docker exec -it lhrora11204 bash
[root@lhrora11204 /]# su  - oracle
 
[oracle@lhrora11204 ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 01-SEP-2023 01:47:59

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/lhrora11204/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhrora11204)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                01-SEP-2023 01:48:01
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.4/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/lhrora11204/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lhrora11204)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@lhrora11204 ~]$  sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Sep 1 01:48:05 2023

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SYS@LHR11G> startup
ORACLE instance started.

Total System Global Area  325685248 bytes
Fixed Size            2252944 bytes
Variable Size          184553328 bytes
Database Buffers      134217728 bytes
Redo Buffers            4661248 bytes
Database mounted.
Database opened.
SYS@LHR11G> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@lhrora11204 ~]$


 

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐