原 【DB宝30】使用Docker测试Oracle 11g高可用DG功能
Tags: Oracle原创Linux高可用Docker小麦苗DG
一、下载镜像
小麦苗DG环境的hub地址:
https://hub.docker.com/r/lhrbest/dg_pri_11.2.0.4/tags
https://hub.docker.com/r/lhrbest/dg_phy_11.2.0.4/tags
1 2 | nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/dg_phy_11.2.0.4:1.0 & nohup docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/dg_pri_11.2.0.4:1.0 & |
查看镜像:
1 2 3 | [root@docker36 ~]# docker images | grep dg registry.cn-hangzhou.aliyuncs.com/lhrbest/dg_phy_11.2.0.4 1.0 f2ea019fe540 15 hours ago 10.7GB registry.cn-hangzhou.aliyuncs.com/lhrbest/dg_pri_11.2.0.4 1.0 b7fae2029b40 15 hours ago 10.8GB |
给镜像打tag:
1 2 3 4 5 6 7 8 | [root@docker36 ~]# docker tag registry.cn-hangzhou.aliyuncs.com/lhrbest/dg_phy_11.2.0.4:1.0 lhrbest/dg_phy_11.2.0.4:1.0 [root@docker36 ~]# docker tag registry.cn-hangzhou.aliyuncs.com/lhrbest/dg_pri_11.2.0.4:1.0 lhrbest/dg_pri_11.2.0.4:1.0 [root@docker36 ~]# docker images | grep dg lhrbest/dg_phy_11.2.0.4 1.0 f2ea019fe540 15 hours ago 10.7GB registry.cn-hangzhou.aliyuncs.com/lhrbest/dg_phy_11.2.0.4 1.0 f2ea019fe540 15 hours ago 10.7GB lhrbest/dg_pri_11.2.0.4 1.0 b7fae2029b40 15 hours ago 10.8GB registry.cn-hangzhou.aliyuncs.com/lhrbest/dg_pri_11.2.0.4 1.0 b7fae2029b40 15 hours ago 10.8GB |
二、初始化环境
DG环境情况见下表: | 项目 | 主库 | 物理备库 |
---|---|---|---|
db 类型 | 单实例 | 单实例 | |
db version | 11.2.0.4.0 | 11.2.0.4.0 | |
db 存储 | FS | FS | |
OS版本 | RHEL7.6 64位 | CentOS7.6 64位 | |
OS hostname | LHR11G | LHR11GDG | |
IP地址 | 192.168.68.68 | 192.168.68.69 | |
ORACLE_SID | LHR11G | LHR11GDG | |
db_name/GLOBAL_DBNAME | LHR11G | LHR11G | |
db_unique_name | LHR11G | LHR11GDG | |
TNS_NAME | LHR11G | LHR11GDG | |
监听端口 | 1521 | 1521 | |
映射的主机端口 | 1528 | 1529 | |
ORACLE_HOME | /u01/app/oracle/product/11.2.0.4/dbhome_1 | /u01/app/oracle/product/11.2.0.4/dbhome_1 | |
dbid | 2007947551 | 2007947551 |
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 | -- 创建DG的网络 docker network create --subnet=192.168.68.0/16 mhalhr docker network inspect mhalhr -- 分别初始化主库和备库 docker run -itd --name LHR11G -h LHR11G \ -p 1528:1521 -p 1128:1158 -p 228:22 -p 3398:3389 \ --network mhalhr --ip 192.168.68.68 \ --privileged=true \ lhrbest/dg_pri_11.2.0.4:1.0 init docker run -itd --name LHR11GDG -h LHR11GDG \ -p 1529:1521 -p 1129:1158 -p 229:22 -p 3399:3389 \ --network mhalhr --ip 192.168.68.69 \ --privileged=true \ lhrbest/dg_phy_11.2.0.4:1.0 init -- 添加网卡 docker network connect bridge LHR11G docker network connect bridge LHR11GDG -- 进入容器 docker exec -it LHR11G bash docker exec -it LHR11GDG bash -- 分别启动主库、备库和监听 su - oracle lsnrctl start 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 | [root@docker36 ~]# docker exec -it LHR11G bash [root@lhr11g /]# su - oracle [oracle@lhr11g ~]$ sas SQL*Plus: Release 11.2.0.4.0 Production on Wed Oct 28 08:43:43 2020 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 188747632 bytes Database Buffers 130023424 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@lhr11g ~]$ lsnrctl start LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-OCT-2020 08:48:58 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/lhr11g/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=LHR11G)(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 28-OCT-2020 08:48:59 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/lhr11g/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=LHR11G)(PORT=1521))) Services Summary... Service "LHR11G" has 1 instance(s). Instance "LHR11G", status UNKNOWN, has 1 handler(s) for this service... Service "LHR11G_dgmgrl" has 1 instance(s). Instance "LHR11G", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully [oracle@lhr11g ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-OCT-2020 08:49:46 Copyright (c) 1991, 2013, 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.4.0 - Production Start Date 28-OCT-2020 08:48:59 Uptime 0 days 0 hr. 0 min. 47 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/lhr11g/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=LHR11G)(PORT=1521))) Services Summary... Service "LHR11G" has 2 instance(s). Instance "LHR11G", status UNKNOWN, has 1 handler(s) for this service... 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... Service "LHR11G_DGB" has 1 instance(s). Instance "LHR11G", status READY, has 1 handler(s) for this service... Service "LHR11G_dgmgrl" has 1 instance(s). Instance "LHR11G", status UNKNOWN, has 1 handler(s) for this service... Service "dg_taf_lhr" has 1 instance(s). Instance "LHR11G", status READY, has 1 handler(s) for this service... The command completed successfully |
启动备库过程:
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 | [root@docker36 ~]# docker exec -it LHR11GDG bash [root@lhr11gdg /]# su - oracle [oracle@lhr11gdg ~]$ sas SQL*Plus: Release 11.2.0.4.0 Production on Wed Oct 28 08:43:51 2020 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SYS@LHR11GDG> startup ORACLE instance started. Total System Global Area 346562560 bytes Fixed Size 2253144 bytes Variable Size 209718952 bytes Database Buffers 130023424 bytes Redo Buffers 4567040 bytes Database mounted. Database opened. SYS@LHR11GDG> 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@lhr11gdg ~]$ lsnrctl start LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-OCT-2020 08:49:05 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/lhr11gdg/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=LHR11GDG)(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 28-OCT-2020 08:49: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/11.2.0.4/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/lhr11gdg/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=LHR11GDG)(PORT=1521))) Services Summary... Service "LHR11GDG" has 1 instance(s). Instance "LHR11GDG", status UNKNOWN, has 1 handler(s) for this service... Service "LHR11GDG_dgmgrl" has 1 instance(s). Instance "LHR11GDG", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully [oracle@lhr11gdg ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-OCT-2020 08:50:31 Copyright (c) 1991, 2013, 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.4.0 - Production Start Date 28-OCT-2020 08:49:05 Uptime 0 days 0 hr. 1 min. 26 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/lhr11gdg/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=LHR11GDG)(PORT=1521))) Services Summary... Service "LHR11GDG" has 2 instance(s). Instance "LHR11GDG", status UNKNOWN, has 1 handler(s) for this service... Instance "LHR11GDG", status READY, has 1 handler(s) for this service... Service "LHR11GDG_DGB" has 1 instance(s). Instance "LHR11GDG", status READY, has 1 handler(s) for this service... Service "LHR11GDG_dgmgrl" has 1 instance(s). Instance "LHR11GDG", status UNKNOWN, has 1 handler(s) for this service... Service "LHR11GXDB" has 1 instance(s). Instance "LHR11GDG", status READY, has 1 handler(s) for this service... The command completed successfully |
三、测试DG的高可用功能
下面会分别测试DG环境的以下几个功能:
1、验证同步
2、switchover
3、failover
4、fsfo
5、故障切换