注册
主备集群脚本一键自动切换配置说明
专栏/培训园地/ 文章详情 /

主备集群脚本一键自动切换配置说明

The hua 2026/09/16 60 0 0
摘要

为方便进行脚本化运维集群,现整理主备一键切换设置步骤

一、配置wallet存放用户/口令
1.创建 wallet 文件
在/home/dmdba/wallet 路径下创建一个 wallet 文件,文件密码为 Wallet123
[dmdba@localhost ~]$ /home/dmdba/dmdbms/bin/dmmkstore -wrl /home/dmdba/wallet -create
DM Secret Store Tool: V8

Enter password: Wallet123 #秘钥加密密码
Enter password again: Wallet123
2.创建凭据
在 wallet 文件中创建凭据
[dmdba@localhost ~]$ /home/dmdba/dmdbms/bin/dmmkstore -wrl /home/dmdba/wallet -createcredential SYSDBA_KEY SYSDBA SYSDBA
DM Secret Store Tool: V8

Enter wallet password:
Create credential DM.security.client.connect_string1
3.查看凭据
查看 wallet 文件中的凭据。
#查看存放凭据
[dmdba@localhost ~]$ /home/dmdba/dmdbms/bin/dmmkstore -wrl /home/dmdba/wallet -listCredential
DM Secret Store Tool: V8

Enter wallet password:
List credential (index: connect_string username)
1: SYSDBA_KEY SYSDBA

#显示所有凭据条目
[dmdba@localhost ~]$ /home/dmdba/dmdbms/bin/dmmkstore -wrl /home/dmdba/wallet -list
DM Secret Store Tool: V8

Enter wallet password:
DM Secret Store entries:
DM.security.client.connect_string1
DM.security.client.password1
DM.security.client.username1

#显示凭据内指定条目值
[dmdba@localhost ~]$ /home/dmdba/dmdbms/bin/dmmkstore -wrl /home/dmdba/wallet -viewEntry DM.security.client.password1
DM Secret Store Tool: V8

Enter wallet password:
DM.security.client.password1 = SYSDBA
二、新增/调整非确认监视器文件
新增dmmonitor.ini参数MON_WALLET_LOCATION,用于指定wallet文件路径。该参数的值必须为一个合法的路径串,若参数值为空,或该路径合法但无效,监视器也可以正常启动,但在使用wallet方式进行登录时会报错。此参数为公共配置信息,不支持对每个group分别指定,若在同一个文件中存在多个配置,以最后一次的配置为准,配置方式举例:
MON_DW_CONFIRM = 1
MON_LOG_PATH = dm/data/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0
MON_WALLET_LOCATION = /home/dmdba/wallet #dmwallet.prikey文件所在路径
[GRP1]
MON_INST_OGUID = 453331
MON_DW_IP = 192.168.0.141:52141 #根据主备集群dmmal.ini配置
MON_DW_IP = 192.168.0.142:52142 #根据主备集群dmmal.ini配置
三、配置自动切换脚本
新增监视器登录方式:login /@service_name,其中"/@"为固定用法,沿用自disql,service_name是服务名,最长为128,超长则报错。可以从钱包中根据服务名找到相对应的用户名和口令,这里的用户名及口令和服务器的登录口令是一致的,且必须有SYSDBA权限,才能成功登录监视器。
1.DB01切换到DB02脚本
[dmdba@localhost ~]$ cat dmmonitor_auto_switchover_db01_to_db02.sh
#!/bin/bash

date

cd /home/dmdba/dmdbms/bin
./dmmonitor /home/dmdba/dmdata/dmmon/DAMENG/dmmonitor_manual.ini << EOF

SHOW

TIP

LOGIN /@SYSDBA_KEY

SWITCHOVER GRP1_RT_2

SHOW

TIP

EXIT

EOF

date

2.DB02切换到DB01脚本
[dmdba@localhost ~]$ cat dmmonitor_auto_switchover_db02_to_db01.sh
#!/bin/bash

date

cd /home/dmdba/dmdbms/bin
./dmmonitor /home/dmdba/dmdata/dmmon/DAMENG/dmmonitor_manual.ini << EOF

SHOW

TIP

LOGIN /@SYSDBA_KEY

SWITCHOVER GRP1_RT_1

SHOW

TIP

EXIT

EOF

date
四、自动切换
1.DB01节点切换到DB02节点
[dmdba@localhost ~]$ bash dmmonitor_auto_switchover_db01_to_db02.sh
[monitor] 2024-05-14 03:44:55: DMMONITOR[4.0] V8
[monitor] 2024-05-14 03:44:56: DMMONITOR[4.0] IS READY.

[monitor] 2024-05-14 03:44:56:
#--------------------------------------------------------------------------------#
GET MONITOR CONNECT INFO FROM DMWATCHER(GRP1_RT_2), THE FIRST LINE IS SELF INFO.

DW_CONN_TIME MON_CONFIRM MID MON_IP MON_VERSION
2024-05-14 03:44:56 FALSE 2096789224 ::ffff:192.168.0.132 DMMONITOR[4.0] V8

2024-05-14 02:10:20 TRUE 272657224 ::ffff:192.168.0.132 DMMONITOR[4.0] V8

#--------------------------------------------------------------------------------#

[monitor] 2024-05-14 03:44:56: Received message from(GRP1_RT_2)
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2024-05-14 03:44:56 OPEN OK GRP1_RT_2 OPEN STANDBY NULL 7 43582 43582

[monitor] 2024-05-14 03:44:56: Received message from(GRP1_RT_1)
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2024-05-14 18:44:56 OPEN OK GRP1_RT_1 OPEN PRIMARY VALID 7 43582 43582

Input command illegal, please input help to get the help information!

2024-05-14 03:44:56
#================================================================================#
GROUP OGUID MON_CONFIRM MODE MPP_FLAG
GRP1 453331 FALSE AUTO FALSE

<>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
192.168.0.131 52141 2024-05-14 18:44:56 GLOBAL VALID OPEN GRP1_RT_1 OK 1 1 OPEN PRIMARY DSC_OPEN REALTIME VALID

EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
192.168.0.131 32141 OK GRP1_RT_1 OPEN PRIMARY 0 0 REALTIME VALID 5140 43582 5140 43582 NONE

<>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
192.168.0.132 52142 2024-05-14 03:44:56 GLOBAL VALID OPEN GRP1_RT_2 OK 1 1 OPEN STANDBY DSC_OPEN REALTIME VALID

EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
192.168.0.132 32142 OK GRP1_RT_2 OPEN STANDBY 0 0 REALTIME VALID 5140 43582 5140 43582 NONE

DATABASE(GRP1_RT_2) APPLY INFO FROM (GRP1_RT_1), REDOS_PARALLEL_NUM (1), WAIT_APPLY[FALSE]:
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[5140, 5140, 5140], (RLSN, SLSN, KLSN)[43582, 43582, 43582], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (43582)

#================================================================================#

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

[monitor] 2024-05-14 03:44:56: [!!! TIP: This dmmonitor is not in CONFIRM mode, if PRIMARY instance error occurs in AUTO watch mode, this dmmonitor cannot do auto takeover !!!]

[monitor] 2024-05-14 03:44:56: Instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE] cannot join other instances, dmwatcher status is OPEN, SYSOPENHISTORY status is VALID
[monitor] 2024-05-14 03:44:56: Instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE] has no command to execute currently
[monitor] 2024-05-14 03:44:56: Instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE] is OK, dmwatcher status is OPEN, dw_type is GLOBAL

[monitor] 2024-05-14 03:44:56: Instance GRP1_RT_2[STANDBY, OPEN, ISTAT_SAME:TRUE] can join instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE]
[monitor] 2024-05-14 03:44:56: Instance GRP1_RT_2[STANDBY, OPEN, ISTAT_SAME:TRUE] has no command to execute currently
[monitor] 2024-05-14 03:44:56: Instance GRP1_RT_2[STANDBY, OPEN, ISTAT_SAME:TRUE] is OK, dmwatcher status is OPEN, dw_type is GLOBAL

[monitor] 2024-05-14 03:44:56: Group(GRP1) current active instances are OK

[monitor] 2024-05-14 03:44:56: All groups' current active instances are OK!

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

2024-05-14 03:44:58
#================================================================================#
GROUP OGUID MON_CONFIRM MODE MPP_FLAG
GRP1 453331 FALSE AUTO FALSE

<>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
192.168.0.131 52141 2024-05-14 18:44:57 GLOBAL VALID OPEN GRP1_RT_1 OK 1 1 OPEN PRIMARY DSC_OPEN REALTIME VALID

EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
192.168.0.131 32141 OK GRP1_RT_1 OPEN PRIMARY 0 0 REALTIME VALID 5140 43582 5140 43582 NONE

<>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
192.168.0.132 52142 2024-05-14 03:44:57 GLOBAL VALID OPEN GRP1_RT_2 OK 1 1 OPEN STANDBY DSC_OPEN REALTIME VALID

EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
192.168.0.132 32142 OK GRP1_RT_2 OPEN STANDBY 0 0 REALTIME VALID 5140 43582 5140 43582 NONE

DATABASE(GRP1_RT_2) APPLY INFO FROM (GRP1_RT_1), REDOS_PARALLEL_NUM (1), WAIT_APPLY[FALSE]:
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[5140, 5140, 5140], (RLSN, SLSN, KLSN)[43582, 43582, 43582], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (43582)

#================================================================================#

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

[monitor] 2024-05-14 03:44:58: Login dmmonitor success!

[monitor] 2024-05-14 03:44:58: [!!! TIP: This dmmonitor is not in CONFIRM mode, if PRIMARY instance error occurs in AUTO watch mode, this dmmonitor cannot do auto takeover !!!]

[monitor] 2024-05-14 03:44:58: Instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE] cannot join other instances, dmwatcher status is OPEN, SYSOPENHISTORY status is VALID
[monitor] 2024-05-14 03:44:58: Instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE] has no command to execute currently
[monitor] 2024-05-14 03:44:58: Instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE] is OK, dmwatcher status is OPEN, dw_type is GLOBAL

[monitor] 2024-05-14 03:44:58: Instance GRP1_RT_2[STANDBY, OPEN, ISTAT_SAME:TRUE] can join instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE]
[monitor] 2024-05-14 03:44:58: Instance GRP1_RT_2[STANDBY, OPEN, ISTAT_SAME:TRUE] has no command to execute currently
[monitor] 2024-05-14 03:44:58: Instance GRP1_RT_2[STANDBY, OPEN, ISTAT_SAME:TRUE] is OK, dmwatcher status is OPEN, dw_type is GLOBAL

[monitor] 2024-05-14 03:44:58: Group(GRP1) current active instances are OK

[monitor] 2024-05-14 03:44:58: All groups' current active instances are OK!

^C[dmdba@localhost ~]vi dmmonitor_auto_switchover_db01_to_db02.shh
[dmdba@localhost ~]$ bash dmmonitor_auto_switchover_db01_to_db02.sh
[dmdba@localhost ~]$ bash dmmonitor_auto_switchover_db01_to_db02.sh
[monitor] 2024-05-14 03:45:24: DMMONITOR[4.0] V8
[monitor] 2024-05-14 03:45:25: DMMONITOR[4.0] IS READY.

[monitor] 2024-05-14 03:45:25:
#--------------------------------------------------------------------------------#
GET MONITOR CONNECT INFO FROM DMWATCHER(GRP1_RT_2), THE FIRST LINE IS SELF INFO.

DW_CONN_TIME MON_CONFIRM MID MON_IP MON_VERSION
2024-05-14 03:45:25 FALSE 1895048944 ::ffff:192.168.0.132 DMMONITOR[4.0] V8

2024-05-14 02:10:20 TRUE 272657224 ::ffff:192.168.0.132 DMMONITOR[4.0] V8

#--------------------------------------------------------------------------------#

[monitor] 2024-05-14 03:45:25: Received message from(GRP1_RT_2)
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2024-05-14 03:45:25 OPEN OK GRP1_RT_2 OPEN STANDBY NULL 7 43582 43582

[monitor] 2024-05-14 03:45:25: Received message from(GRP1_RT_1)
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2024-05-14 18:45:25 OPEN OK GRP1_RT_1 OPEN PRIMARY VALID 7 43582 43582

Input command illegal, please input help to get the help information!

2024-05-14 03:45:25
#================================================================================#
GROUP OGUID MON_CONFIRM MODE MPP_FLAG
GRP1 453331 FALSE AUTO FALSE

<>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
192.168.0.131 52141 2024-05-14 18:45:25 GLOBAL VALID OPEN GRP1_RT_1 OK 1 1 OPEN PRIMARY DSC_OPEN REALTIME VALID

EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
192.168.0.131 32141 OK GRP1_RT_1 OPEN PRIMARY 0 0 REALTIME VALID 5140 43582 5140 43582 NONE

<>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
192.168.0.132 52142 2024-05-14 03:45:25 GLOBAL VALID OPEN GRP1_RT_2 OK 1 1 OPEN STANDBY DSC_OPEN REALTIME VALID

EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
192.168.0.132 32142 OK GRP1_RT_2 OPEN STANDBY 0 0 REALTIME VALID 5140 43582 5140 43582 NONE

DATABASE(GRP1_RT_2) APPLY INFO FROM (GRP1_RT_1), REDOS_PARALLEL_NUM (1), WAIT_APPLY[FALSE]:
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[5140, 5140, 5140], (RLSN, SLSN, KLSN)[43582, 43582, 43582], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (43582)

#================================================================================#

....(因篇幅问题省略部门分析)

[monitor] 2024-05-14 03:45:25: [!!! TIP: This dmmonitor is not in CONFIRM mode, if PRIMARY instance error occurs in AUTO watch mode, this dmmonitor cannot do auto takeover !!!]

[monitor] 2024-05-14 03:45:25: Instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE] cannot join other instances, dmwatcher status is OPEN, SYSOPENHISTORY status is VALID
[monitor] 2024-05-14 03:45:25: Instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE] has no command to execute currently
[monitor] 2024-05-14 03:45:25: Instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE] is OK, dmwatcher status is OPEN, dw_type is GLOBAL

[monitor] 2024-05-14 03:45:25: Instance GRP1_RT_2[STANDBY, OPEN, ISTAT_SAME:TRUE] can join instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE]
[monitor] 2024-05-14 03:45:25: Instance GRP1_RT_2[STANDBY, OPEN, ISTAT_SAME:TRUE] has no command to execute currently
[monitor] 2024-05-14 03:45:25: Instance GRP1_RT_2[STANDBY, OPEN, ISTAT_SAME:TRUE] is OK, dmwatcher status is OPEN, dw_type is GLOBAL

[monitor] 2024-05-14 03:45:25: Group(GRP1) current active instances are OK

[monitor] 2024-05-14 03:45:25: All groups' current active instances are OK!

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

[monitor] 2024-05-14 03:45:27: Login dmmonitor success!

[monitor] 2024-05-14 03:45:29: Start to switchover instance GRP1_RT_2
[monitor] 2024-05-14 03:45:29: Notify dmwatcher(GRP1_RT_1) switch to SWITCHOVER status
[monitor] 2024-05-14 03:45:29: Dmwatcher process GRP1_RT_1 status switching [OPEN-->SWITCHOVER]
[monitor] 2024-05-14 03:45:30: Switch dmwatcher GRP1_RT_1 to SWITCHOVER status success
[monitor] 2024-05-14 03:45:30: Notify dmwatcher(GRP1_RT_2) switch to SWITCHOVER status
[monitor] 2024-05-14 03:45:30: Dmwatcher process GRP1_RT_2 status switching [OPEN-->SWITCHOVER]
[monitor] 2024-05-14 03:45:31: Switch dmwatcher GRP1_RT_2 to SWITCHOVER status success
[monitor] 2024-05-14 03:45:31: Instance GRP1_RT_1 start to execute sql SP_SET_GLOBAL_DW_STATUS(0, 6)
[monitor] 2024-05-14 03:45:31: Instance GRP1_RT_1 execute sql SP_SET_GLOBAL_DW_STATUS(0, 6) success
[monitor] 2024-05-14 03:45:31: Instance GRP1_RT_2 start to execute sql SP_SET_GLOBAL_DW_STATUS(0, 6)
[monitor] 2024-05-14 03:45:31: Instance GRP1_RT_2 execute sql SP_SET_GLOBAL_DW_STATUS(0, 6) success
[monitor] 2024-05-14 03:45:31: Instance GRP1_RT_1 start to execute sql ALTER DATABASE MOUNT
[monitor] 2024-05-14 03:45:31: Instance GRP1_RT_1 execute sql ALTER DATABASE MOUNT success
[monitor] 2024-05-14 03:45:31: Instance GRP1_RT_2 start to execute sql SP_APPLY_KEEP_PKG()
[monitor] 2024-05-14 03:45:32: Instance GRP1_RT_2 execute sql SP_APPLY_KEEP_PKG() success
[monitor] 2024-05-14 03:45:32: Instance GRP1_RT_2 start to execute sql ALTER DATABASE MOUNT
[monitor] 2024-05-14 03:45:32: Instance GRP1_RT_2 execute sql ALTER DATABASE MOUNT success
[monitor] 2024-05-14 03:45:32: Instance GRP1_RT_1 start to execute sql ALTER DATABASE STANDBY
[monitor] 2024-05-14 03:45:33: Instance GRP1_RT_1 execute sql ALTER DATABASE STANDBY success
[monitor] 2024-05-14 03:45:33: Instance GRP1_RT_2 start to execute sql ALTER DATABASE PRIMARY
[monitor] 2024-05-14 03:45:33: Instance GRP1_RT_2 execute sql ALTER DATABASE PRIMARY success
[monitor] 2024-05-14 03:45:33: Notify instance GRP1_RT_2 to change all arch status to be invalid
[monitor] 2024-05-14 03:45:33: Succeed to change all instances arch status to be invalid
[monitor] 2024-05-14 03:45:33: Instance GRP1_RT_1 start to execute sql ALTER DATABASE OPEN FORCE
[monitor] 2024-05-14 03:45:33: Instance GRP1_RT_1 execute sql ALTER DATABASE OPEN FORCE success
[monitor] 2024-05-14 03:45:33: Instance GRP1_RT_2 start to execute sql ALTER DATABASE OPEN FORCE
[monitor] 2024-05-14 03:45:33: Instance GRP1_RT_2 execute sql ALTER DATABASE OPEN FORCE success
[monitor] 2024-05-14 03:45:33: Instance GRP1_RT_1 start to execute sql SP_SET_GLOBAL_DW_STATUS(6, 0)
[monitor] 2024-05-14 03:45:33: Instance GRP1_RT_1 execute sql SP_SET_GLOBAL_DW_STATUS(6, 0) success
[monitor] 2024-05-14 03:45:33: Instance GRP1_RT_2 start to execute sql SP_SET_GLOBAL_DW_STATUS(6, 0)
[monitor] 2024-05-14 03:45:33: Instance GRP1_RT_2 execute sql SP_SET_GLOBAL_DW_STATUS(6, 0) success
[monitor] 2024-05-14 03:45:33: Notify dmwatcher(GRP1_RT_1) switch to OPEN status
[monitor] 2024-05-14 03:45:33: Dmwatcher process GRP1_RT_1 status switching [SWITCHOVER-->OPEN]
[monitor] 2024-05-14 03:45:34: Switch dmwatcher GRP1_RT_1 to OPEN status success
[monitor] 2024-05-14 03:45:34: Notify dmwatcher(GRP1_RT_2) switch to OPEN status
[monitor] 2024-05-14 03:45:35: Dmwatcher process GRP1_RT_2 status switching [SWITCHOVER-->OPEN]
[monitor] 2024-05-14 03:45:36: Switch dmwatcher GRP1_RT_2 to OPEN status success
[monitor] 2024-05-14 03:45:36: Notify group(GRP1)'s dmwatcher to do clear
[monitor] 2024-05-14 03:45:36: Clean request of dmwatcher processer GRP1_RT_1 success
2024-05-14 03:45:36
#================================================================================#
GROUP OGUID MON_CONFIRM MODE MPP_FLAG
GRP1 453331 FALSE AUTO FALSE

<>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
192.168.0.132 52142 2024-05-14 03:45:36 GLOBAL VALID OPEN GRP1_RT_2 OK 1 1 OPEN PRIMARY DSC_OPEN REALTIME VALID

EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
192.168.0.132 32142 OK GRP1_RT_2 OPEN PRIMARY 0 0 REALTIME VALID 5143 43768 5143 43768 NONE

<>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
192.168.0.131 52141 2024-05-14 18:45:36 GLOBAL VALID OPEN GRP1_RT_1 OK 1 1 OPEN STANDBY DSC_OPEN REALTIME INVALID

EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
192.168.0.131 32141 OK GRP1_RT_1 OPEN STANDBY 0 0 REALTIME INVALID 5141 43583 5141 43583 NONE

DATABASE(GRP1_RT_1) APPLY INFO FROM (GRP1_RT_2), REDOS_PARALLEL_NUM (1), WAIT_APPLY[FALSE]:
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[5141, 5141, 5141], (RLSN, SLSN, KLSN)[43583, 43583, 43583], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (43583)

#================================================================================#

Input command illegal, please input help to get the help information!

2024-05-14 03:45:36
#================================================================================#
GROUP OGUID MON_CONFIRM MODE MPP_FLAG
GRP1 453331 FALSE AUTO FALSE

<>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
192.168.0.132 52142 2024-05-14 03:45:36 GLOBAL VALID OPEN GRP1_RT_2 OK 1 1 OPEN PRIMARY DSC_OPEN REALTIME VALID

EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
192.168.0.132 32142 OK GRP1_RT_2 OPEN PRIMARY 0 0 REALTIME VALID 5143 43768 5143 43768 NONE

<>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
192.168.0.131 52141 2024-05-14 18:45:36 GLOBAL VALID OPEN GRP1_RT_1 OK 1 1 OPEN STANDBY DSC_OPEN REALTIME INVALID

EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
192.168.0.131 32141 OK GRP1_RT_1 OPEN STANDBY 0 0 REALTIME INVALID 5141 43583 5141 43583 NONE

DATABASE(GRP1_RT_1) APPLY INFO FROM (GRP1_RT_2), REDOS_PARALLEL_NUM (1), WAIT_APPLY[FALSE]:
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[5141, 5141, 5141], (RLSN, SLSN, KLSN)[43583, 43583, 43583], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (43583)

#================================================================================#

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

[monitor] 2024-05-14 03:45:36: Clean request of dmwatcher processer GRP1_RT_2 success
[monitor] 2024-05-14 03:45:36: Switchover instance GRP1_RT_2 success

[monitor] 2024-05-14 03:45:36: [!!! TIP: This dmmonitor is not in CONFIRM mode, if PRIMARY instance error occurs in AUTO watch mode, this dmmonitor cannot do auto takeover !!!]

[monitor] 2024-05-14 03:45:36: Instance GRP1_RT_2[PRIMARY, OPEN, ISTAT_SAME:TRUE] cannot join other instances, dmwatcher status is OPEN, SYSOPENHISTORY status is VALID
[monitor] 2024-05-14 03:45:36: Instance GRP1_RT_2[PRIMARY, OPEN, ISTAT_SAME:TRUE] has no command to execute currently
[monitor] 2024-05-14 03:45:36: Instance GRP1_RT_2[PRIMARY, OPEN, ISTAT_SAME:TRUE] is OK, dmwatcher status is OPEN, dw_type is GLOBAL

[monitor] 2024-05-14 03:45:36: Instance GRP1_RT_1[STANDBY, OPEN, ISTAT_SAME:TRUE] can join instance GRP1_RT_2[PRIMARY, OPEN, ISTAT_SAME:TRUE]
[monitor] 2024-05-14 03:45:36: Instance GRP1_RT_1[STANDBY, OPEN, ISTAT_SAME:TRUE] has no command to execute currently
[monitor] 2024-05-14 03:45:36: Instance GRP1_RT_1[STANDBY, OPEN, ISTAT_SAME:TRUE] arch status is invalid, but it cannot be recovered now, please retry later, can use CHECK RECOVER command to find detail reason

[monitor] 2024-05-14 03:45:36: Group(GRP1) has PRIMARY&OPEN instance, but still exists other instances not OK, please choose appropriate processing according to the above information!

[monitor] 2024-05-14 03:45:36: All groups' have PRIMARY&OPEN instances, but there still exist instances not OK!

[monitor] 2024-05-14 03:45:37: Dmwatcher process GRP1_RT_2 status switching [OPEN-->RECOVERY]
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2024-05-14 03:45:37 RECOVERY OK GRP1_RT_2 OPEN PRIMARY VALID 8 43768 43768

[monitor] 2024-05-14 03:45:39: Dmwatcher process GRP1_RT_2 status switching [RECOVERY-->OPEN]
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2024-05-14 03:45:39 OPEN OK GRP1_RT_2 OPEN PRIMARY VALID 8 43768 43768

2.DB02节点切换到DB01节点
[dmdba@localhost ~]$ bash dmmonitor_auto_switchover_db02_to_db01.sh
Tue May 14 03:51:46 PDT 2024
[monitor] 2024-05-14 03:51:46: DMMONITOR[4.0] V8
[monitor] 2024-05-14 03:51:47: DMMONITOR[4.0] IS READY.

[monitor] 2024-05-14 03:51:47:
#--------------------------------------------------------------------------------#
GET MONITOR CONNECT INFO FROM DMWATCHER(GRP1_RT_1), THE FIRST LINE IS SELF INFO.

DW_CONN_TIME MON_CONFIRM MID MON_IP MON_VERSION
2024-05-14 18:51:47 FALSE 263437045 ::ffff:192.168.0.132 DMMONITOR[4.0] V8

2024-05-14 17:13:28 TRUE 272657224 ::ffff:192.168.0.132 DMMONITOR[4.0] V8

#--------------------------------------------------------------------------------#

[monitor] 2024-05-14 03:51:47: Received message from(GRP1_RT_1)
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2024-05-14 18:51:47 OPEN OK GRP1_RT_1 OPEN STANDBY NULL 8 43768 43768

[monitor] 2024-05-14 03:51:47: Received message from(GRP1_RT_2)
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2024-05-14 03:51:47 OPEN OK GRP1_RT_2 OPEN PRIMARY VALID 8 43768 43768

Input command illegal, please input help to get the help information!

2024-05-14 03:51:47
#================================================================================#
GROUP OGUID MON_CONFIRM MODE MPP_FLAG
GRP1 453331 FALSE AUTO FALSE

<>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
192.168.0.132 52142 2024-05-14 03:51:47 GLOBAL VALID OPEN GRP1_RT_2 OK 1 1 OPEN PRIMARY DSC_OPEN REALTIME VALID

EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
192.168.0.132 32142 OK GRP1_RT_2 OPEN PRIMARY 0 0 REALTIME VALID 5145 43768 5145 43768 NONE

<>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
192.168.0.131 52141 2024-05-14 18:51:47 GLOBAL VALID OPEN GRP1_RT_1 OK 1 1 OPEN STANDBY DSC_OPEN REALTIME VALID

EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
192.168.0.131 32141 OK GRP1_RT_1 OPEN STANDBY 0 0 REALTIME VALID 5145 43768 5145 43768 NONE

DATABASE(GRP1_RT_1) APPLY INFO FROM (GRP1_RT_2), REDOS_PARALLEL_NUM (1), WAIT_APPLY[FALSE]:
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[5145, 5145, 5145], (RLSN, SLSN, KLSN)[43768, 43768, 43768], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (43768)

#================================================================================#

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

[monitor] 2024-05-14 03:51:47: [!!! TIP: This dmmonitor is not in CONFIRM mode, if PRIMARY instance error occurs in AUTO watch mode, this dmmonitor cannot do auto takeover !!!]

[monitor] 2024-05-14 03:51:47: Instance GRP1_RT_2[PRIMARY, OPEN, ISTAT_SAME:TRUE] cannot join other instances, dmwatcher status is OPEN, SYSOPENHISTORY status is VALID
[monitor] 2024-05-14 03:51:47: Instance GRP1_RT_2[PRIMARY, OPEN, ISTAT_SAME:TRUE] has no command to execute currently
[monitor] 2024-05-14 03:51:47: Instance GRP1_RT_2[PRIMARY, OPEN, ISTAT_SAME:TRUE] is OK, dmwatcher status is OPEN, dw_type is GLOBAL

[monitor] 2024-05-14 03:51:47: Instance GRP1_RT_1[STANDBY, OPEN, ISTAT_SAME:TRUE] can join instance GRP1_RT_2[PRIMARY, OPEN, ISTAT_SAME:TRUE]
[monitor] 2024-05-14 03:51:47: Instance GRP1_RT_1[STANDBY, OPEN, ISTAT_SAME:TRUE] has no command to execute currently
[monitor] 2024-05-14 03:51:47: Instance GRP1_RT_1[STANDBY, OPEN, ISTAT_SAME:TRUE] is OK, dmwatcher status is OPEN, dw_type is GLOBAL

[monitor] 2024-05-14 03:51:47: Group(GRP1) current active instances are OK

[monitor] 2024-05-14 03:51:47: All groups' current active instances are OK!

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

[monitor] 2024-05-14 03:51:48: Login dmmonitor success!

[monitor] 2024-05-14 03:51:51: Start to switchover instance GRP1_RT_1
[monitor] 2024-05-14 03:51:51: Notify dmwatcher(GRP1_RT_2) switch to SWITCHOVER status
[monitor] 2024-05-14 03:51:51: Dmwatcher process GRP1_RT_2 status switching [OPEN-->SWITCHOVER]
[monitor] 2024-05-14 03:51:52: Switch dmwatcher GRP1_RT_2 to SWITCHOVER status success
[monitor] 2024-05-14 03:51:52: Notify dmwatcher(GRP1_RT_1) switch to SWITCHOVER status
[monitor] 2024-05-14 03:51:52: Dmwatcher process GRP1_RT_1 status switching [OPEN-->SWITCHOVER]
[monitor] 2024-05-14 03:51:53: Switch dmwatcher GRP1_RT_1 to SWITCHOVER status success
[monitor] 2024-05-14 03:51:53: Instance GRP1_RT_2 start to execute sql SP_SET_GLOBAL_DW_STATUS(0, 6)
[monitor] 2024-05-14 03:51:53: Instance GRP1_RT_2 execute sql SP_SET_GLOBAL_DW_STATUS(0, 6) success
[monitor] 2024-05-14 03:51:53: Instance GRP1_RT_1 start to execute sql SP_SET_GLOBAL_DW_STATUS(0, 6)
[monitor] 2024-05-14 03:51:53: Instance GRP1_RT_1 execute sql SP_SET_GLOBAL_DW_STATUS(0, 6) success
[monitor] 2024-05-14 03:51:53: Instance GRP1_RT_2 start to execute sql ALTER DATABASE MOUNT
[monitor] 2024-05-14 03:51:53: Instance GRP1_RT_2 execute sql ALTER DATABASE MOUNT success
[monitor] 2024-05-14 03:51:53: Instance GRP1_RT_1 start to execute sql SP_APPLY_KEEP_PKG()
[monitor] 2024-05-14 03:51:53: Instance GRP1_RT_1 execute sql SP_APPLY_KEEP_PKG() success
[monitor] 2024-05-14 03:51:53: Instance GRP1_RT_1 start to execute sql ALTER DATABASE MOUNT
[monitor] 2024-05-14 03:51:53: Instance GRP1_RT_1 execute sql ALTER DATABASE MOUNT success
[monitor] 2024-05-14 03:51:53: Instance GRP1_RT_2 start to execute sql ALTER DATABASE STANDBY
[monitor] 2024-05-14 03:51:54: Instance GRP1_RT_2 execute sql ALTER DATABASE STANDBY success
[monitor] 2024-05-14 03:51:54: Instance GRP1_RT_1 start to execute sql ALTER DATABASE PRIMARY
[monitor] 2024-05-14 03:51:54: Instance GRP1_RT_1 execute sql ALTER DATABASE PRIMARY success
[monitor] 2024-05-14 03:51:54: Notify instance GRP1_RT_1 to change all arch status to be invalid
[monitor] 2024-05-14 03:51:55: Succeed to change all instances arch status to be invalid
[monitor] 2024-05-14 03:51:55: Instance GRP1_RT_2 start to execute sql ALTER DATABASE OPEN FORCE
[monitor] 2024-05-14 03:51:56: Instance GRP1_RT_2 execute sql ALTER DATABASE OPEN FORCE success
[monitor] 2024-05-14 03:51:56: Instance GRP1_RT_1 start to execute sql ALTER DATABASE OPEN FORCE
[monitor] 2024-05-14 03:51:56: Instance GRP1_RT_1 execute sql ALTER DATABASE OPEN FORCE success
[monitor] 2024-05-14 03:51:56: Instance GRP1_RT_2 start to execute sql SP_SET_GLOBAL_DW_STATUS(6, 0)
[monitor] 2024-05-14 03:51:56: Instance GRP1_RT_2 execute sql SP_SET_GLOBAL_DW_STATUS(6, 0) success
[monitor] 2024-05-14 03:51:56: Instance GRP1_RT_1 start to execute sql SP_SET_GLOBAL_DW_STATUS(6, 0)
[monitor] 2024-05-14 03:51:56: Instance GRP1_RT_1 execute sql SP_SET_GLOBAL_DW_STATUS(6, 0) success
[monitor] 2024-05-14 03:51:56: Notify dmwatcher(GRP1_RT_2) switch to OPEN status
[monitor] 2024-05-14 03:51:56: Dmwatcher process GRP1_RT_2 status switching [SWITCHOVER-->OPEN]
[monitor] 2024-05-14 03:51:56: Switch dmwatcher GRP1_RT_2 to OPEN status success
[monitor] 2024-05-14 03:51:56: Notify dmwatcher(GRP1_RT_1) switch to OPEN status
[monitor] 2024-05-14 03:51:56: Dmwatcher process GRP1_RT_1 status switching [SWITCHOVER-->OPEN]
[monitor] 2024-05-14 03:51:57: Switch dmwatcher GRP1_RT_1 to OPEN status success
[monitor] 2024-05-14 03:51:57: Notify group(GRP1)'s dmwatcher to do clear
[monitor] 2024-05-14 03:51:57: Clean request of dmwatcher processer GRP1_RT_1 success
2024-05-14 03:51:57

[monitor] 2024-05-14 03:51:57: Clean request of dmwatcher processer GRP1_RT_2 success
[monitor] 2024-05-14 03:51:57: Switchover instance GRP1_RT_1 success

[monitor] 2024-05-14 03:51:57: [!!! TIP: This dmmonitor is not in CONFIRM mode, if PRIMARY instance error occurs in AUTO watch mode, this dmmonitor cannot do auto takeover !!!]

[monitor] 2024-05-14 03:51:57: Instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE] cannot join other instances, dmwatcher status is OPEN, SYSOPENHISTORY status is VALID
[monitor] 2024-05-14 03:51:57: Instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE] has no command to execute currently
[monitor] 2024-05-14 03:51:57: Instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE] is OK, dmwatcher status is OPEN, dw_type is GLOBAL

[monitor] 2024-05-14 03:51:57: Instance GRP1_RT_2[STANDBY, OPEN, ISTAT_SAME:TRUE] can join instance GRP1_RT_1[PRIMARY, OPEN, ISTAT_SAME:TRUE]
[monitor] 2024-05-14 03:51:57: Instance GRP1_RT_2[STANDBY, OPEN, ISTAT_SAME:TRUE] has no command to execute currently
[monitor] 2024-05-14 03:51:57: Instance GRP1_RT_2[STANDBY, OPEN, ISTAT_SAME:TRUE] arch status is invalid, but it cannot be recovered now, please retry later, can use CHECK RECOVER command to find detail reason

[monitor] 2024-05-14 03:51:57: Group(GRP1) has PRIMARY&OPEN instance, but still exists other instances not OK, please choose appropriate processing according to the above information!

[monitor] 2024-05-14 03:51:57: All groups' have PRIMARY&OPEN instances, but there still exist instances not OK!

Tue May 14 03:52:00 PDT 2024
五、查询节点切换后状态
登录主备库,查询节点状态
#登录主库
[dmdba@localhost ~]$ disql SYSDBA/SYSDBA:32141

Server[LOCALHOST:32142]:mode is primary, state is open
login used time : 3.366(ms)
disql V8
SQL> SELECT MODE$,STATUS$ FROM V$INSTANCE;

LINEID MODE$ STATUS$


1 PRIMARY OPEN

used time: 3.340(ms). Execute id is 1101.
SQL>

#登录备库
[dmdba@localhost ~]$ disql SYSDBA/SYSDBA:32142

Server[LOCALHOST:32142]:mode is standby, state is open
login used time : 3.366(ms)
disql V8
SQL> SELECT MODE$,STATUS$ FROM V$INSTANCE;

LINEID MODE$ STATUS$


1 STANDBY OPEN

used time: 3.340(ms). Execute id is 1101.
SQL>

评论
后发表回复

作者

文章

阅读量

获赞

扫一扫
联系客服