1.使用root用户登录到tsa01和tsa02节点

[root@tsa01 ~]# lsrpdomain
Name OpState RSCTActiveVersion MixedVersions TSPort GSPort
db2ha Online 3.2.5.3 No 12347 12348
[root@tsa01 ~]# lsrpnode
Name OpState RSCTVersion
tsa02 Online 3.2.5.3
tsa01 Online 3.2.5.3

[root@tsa02 ~]# lsrpdomain
Name OpState RSCTActiveVersion MixedVersions TSPort GSPort
db2ha Online 3.2.5.3 No 12347 12348
[root@tsa02 ~]# lsrpnode
Name OpState RSCTVersion
tsa02 Online 3.2.5.3
tsa01 Online 3.2.5.3

2.查看HADR状态

[root@tsa01 ~]# su - db2inst1 -c 'db2pd -d testdb -hadr | egrep "HADR_ROLE|HADR_STATE"'
HADR_ROLE = PRIMARY
HADR_STATE = PEER

[root@tsa02 ~]# su - db2inst1 -c 'db2pd -d testdb -hadr | egrep "HADR_ROLE|HADR_STATE"'
HADR_ROLE = STANDBY
HADR_STATE = PEER

3.查看rg名称
root用户登录到tsa01, tsa02任意一台

[root@tsa01 ~]# lsrg
Resource Group names:
db2_db2inst1_db2inst1_TESTDB-rg
db2_db2inst1_tsa01_0-rg
db2_db2inst1_tsa02_0-rg

4.执行命令切换

[root@tsa01 ~]# rgreq -o move db2_db2inst1_db2inst1_TESTDB-rg
Completed applying request to resource group "db2_db2inst1_db2inst1_TESTDB-rg".

5.再次查看HADR状态,发现HADR角色已经发生改变​

[root@tsa01 ~]# su - db2inst1 -c 'db2pd -d testdb -hadr | egrep "HADR_ROLE|HADR_STATE"'
HADR_ROLE = STANDBY
HADR_STATE = PEER

[root@tsa02 ~]# su - db2inst1 -c 'db2pd -d testdb -hadr | egrep "HADR_ROLE|HADR_STATE"'
HADR_ROLE = PRIMARY
HADR_STATE = PEER

6.切换后查看​

[root@tsa01 ~]# lssam
Online IBM.ResourceGroup:db2_db2inst1_db2inst1_TESTDB-rg Nominal=Online
'- Online IBM.Application:db2_db2inst1_db2inst1_TESTDB-rs
|- Offline IBM.Application:db2_db2inst1_db2inst1_TESTDB-rs:tsa01
'- Online IBM.Application:db2_db2inst1_db2inst1_TESTDB-rs:tsa02
Online IBM.ResourceGroup:db2_db2inst1_tsa01_0-rg Nominal=Online
'- Online IBM.Application:db2_db2inst1_tsa01_0-rs
'- Online IBM.Application:db2_db2inst1_tsa01_0-rs:tsa01
Online IBM.ResourceGroup:db2_db2inst1_tsa02_0-rg Nominal=Online
'- Online IBM.Application:db2_db2inst1_tsa02_0-rs
'- Online IBM.Application:db2_db2inst1_tsa02_0-rs:tsa02
Online IBM.Equivalency:db2_db2inst1_db2inst1_TESTDB-rg_group-equ
|- Online IBM.PeerNode:tsa01:tsa01
'- Online IBM.PeerNode:tsa02:tsa02
Online IBM.Equivalency:db2_db2inst1_tsa01_0-rg_group-equ
'- Online IBM.PeerNode:tsa01:tsa01
Online IBM.Equivalency:db2_db2inst1_tsa02_0-rg_group-equ
'- Online IBM.PeerNode:tsa02:tsa02
Online IBM.Equivalency:db2_public_network_0
|- Online IBM.NetworkInterface:enp0s3:tsa01
'- Online IBM.NetworkInterface:enp0s3:tsa02


[root@tsa02 ~]# lssam
Online IBM.ResourceGroup:db2_db2inst1_db2inst1_TESTDB-rg Nominal=Online
'- Online IBM.Application:db2_db2inst1_db2inst1_TESTDB-rs
|- Offline IBM.Application:db2_db2inst1_db2inst1_TESTDB-rs:tsa01
'- Online IBM.Application:db2_db2inst1_db2inst1_TESTDB-rs:tsa02
Online IBM.ResourceGroup:db2_db2inst1_tsa01_0-rg Nominal=Online
'- Online IBM.Application:db2_db2inst1_tsa01_0-rs
'- Online IBM.Application:db2_db2inst1_tsa01_0-rs:tsa01
Online IBM.ResourceGroup:db2_db2inst1_tsa02_0-rg Nominal=Online
'- Online IBM.Application:db2_db2inst1_tsa02_0-rs
'- Online IBM.Application:db2_db2inst1_tsa02_0-rs:tsa02
Online IBM.Equivalency:db2_db2inst1_db2inst1_TESTDB-rg_group-equ
|- Online IBM.PeerNode:tsa01:tsa01
'- Online IBM.PeerNode:tsa02:tsa02
Online IBM.Equivalency:db2_db2inst1_tsa01_0-rg_group-equ
'- Online IBM.PeerNode:tsa01:tsa01
Online IBM.Equivalency:db2_db2inst1_tsa02_0-rg_group-equ
'- Online IBM.PeerNode:tsa02:tsa02
Online IBM.Equivalency:db2_public_network_0
|- Online IBM.NetworkInterface:enp0s3:tsa01
'- Online IBM.NetworkInterface:enp0s3:tsa02

7.回切
root用户登录到tsa01, tsa02任意一台

[root@tsa01 ~]#   rgreq -o move db2_db2inst1_db2inst1_TESTDB-rg
Completed applying request to resource group "db2_db2inst1_db2inst1_TESTDB-rg".

8.回切后查看HADR状态

[root@tsa01 ~]# su - db2inst1 -c 'db2pd -d testdb -hadr | egrep "HADR_ROLE|HADR_STATE"'
HADR_ROLE = PRIMARY
HADR_STATE = REMOTE_CATCHUP_PENDING

[root@tsa02 ~]# su - db2inst1 -c 'db2pd -d testdb -hadr | egrep "HADR_ROLE|HADR_STATE"'
HADR_ROLE = STANDBY
HADR_STATE = PEER

[root@tsa01 ~]# lssam
Online IBM.ResourceGroup:db2_db2inst1_db2inst1_TESTDB-rg Nominal=Online
'- Online IBM.Application:db2_db2inst1_db2inst1_TESTDB-rs
|- Online IBM.Application:db2_db2inst1_db2inst1_TESTDB-rs:tsa01
'- Offline IBM.Application:db2_db2inst1_db2inst1_TESTDB-rs:tsa02
Online IBM.ResourceGroup:db2_db2inst1_tsa01_0-rg Nominal=Online
'- Online IBM.Application:db2_db2inst1_tsa01_0-rs
'- Online IBM.Application:db2_db2inst1_tsa01_0-rs:tsa01
Online IBM.ResourceGroup:db2_db2inst1_tsa02_0-rg Nominal=Online
'- Online IBM.Application:db2_db2inst1_tsa02_0-rs
'- Online IBM.Application:db2_db2inst1_tsa02_0-rs:tsa02
Online IBM.Equivalency:db2_db2inst1_db2inst1_TESTDB-rg_group-equ
|- Online IBM.PeerNode:tsa01:tsa01
'- Online IBM.PeerNode:tsa02:tsa02
Online IBM.Equivalency:db2_db2inst1_tsa01_0-rg_group-equ
'- Online IBM.PeerNode:tsa01:tsa01
Online IBM.Equivalency:db2_db2inst1_tsa02_0-rg_group-equ
'- Online IBM.PeerNode:tsa02:tsa02
Online IBM.Equivalency:db2_public_network_0
|- Online IBM.NetworkInterface:enp0s3:tsa01
'- Online IBM.NetworkInterface:enp0s3:tsa02

[root@tsa02 ~]# lssam
Online IBM.ResourceGroup:db2_db2inst1_db2inst1_TESTDB-rg Nominal=Online
'- Online IBM.Application:db2_db2inst1_db2inst1_TESTDB-rs
|- Online IBM.Application:db2_db2inst1_db2inst1_TESTDB-rs:tsa01
'- Offline IBM.Application:db2_db2inst1_db2inst1_TESTDB-rs:tsa02
Online IBM.ResourceGroup:db2_db2inst1_tsa01_0-rg Nominal=Online
'- Online IBM.Application:db2_db2inst1_tsa01_0-rs
'- Online IBM.Application:db2_db2inst1_tsa01_0-rs:tsa01
Online IBM.ResourceGroup:db2_db2inst1_tsa02_0-rg Nominal=Online
'- Online IBM.Application:db2_db2inst1_tsa02_0-rs
'- Online IBM.Application:db2_db2inst1_tsa02_0-rs:tsa02
Online IBM.Equivalency:db2_db2inst1_db2inst1_TESTDB-rg_group-equ
|- Online IBM.PeerNode:tsa01:tsa01
'- Online IBM.PeerNode:tsa02:tsa02
Online IBM.Equivalency:db2_db2inst1_tsa01_0-rg_group-equ
'- Online IBM.PeerNode:tsa01:tsa01
Online IBM.Equivalency:db2_db2inst1_tsa02_0-rg_group-equ
'- Online IBM.PeerNode:tsa02:tsa02
Online IBM.Equivalency:db2_public_network_0
|- Online IBM.NetworkInterface:enp0s3:tsa01
'- Online IBM.NetworkInterface:enp0s3:tsa02

版权声明:本文为博主原创文章,未经博主允许不得转载。

DB2