Starting a user-initiated takeover

You can initiate the takeover of a primary HADR host from the standby host on a Pacemaker-managed Db2 instance.

Procedure

  1. As the Db2 instance owner, run a user-initiated takeover from the standby host:
    ./sqllib/bin/db2 takeover hadr on db <database_name>
  2. Validate that the primary role fails over in the crm output. Also, verify that the reads on the standby VIP and primary VIP have switched hosts as expected.
    ./sqllib/bin/crm status
  3. Validate the states of the database using the db2pd command on both hosts:
    New primary:
    ./sqllib/adm/db2pd -db <database_name> -hadr | grep ROLE
                                HADR_ROLE = PRIMARY
    New standby:
    ./sqllib/adm/db2pd -db <database_name> -hadr | grep ROLE
                                HADR_ROLE = STANDBY

Examples

The following example shows the command syntax and output from viewing the initial state of the cluster:
[root@jesting1 ~]# crm status
Stack: corosync
Current DC: jesting1 (version 2.0.2-1.el8-744a30d655) - partition with quorum
Last updated: Tue Mar 10 13:37:52 2020
Last change: Mon Mar  9 09:58:45 2020 by root via cibadmin on inwards1
     
2 nodes configured
7 resources configured
     
Online: [ inwards1 jesting1 ]
    
Full list of resources:
     
db2_inwards1_eth1      (ocf::heartbeat:db2ethmon):     Started inwards1
db2_jesting1_eth1        (ocf::heartbeat:db2ethmon):     Started jesting1
db2_inwards1_db2inst1_0        (ocf::heartbeat:db2inst):       Started inwards1
db2_jesting1_db2inst1_0  (ocf::heartbeat:db2inst):       Started jesting1
Clone Set: db2_db2inst1_db2inst1_SAMPLE-clone [db2_db2inst1_db2inst1_SAMPLE] (promotable)
     Masters: [ inwards1 ]
     Slaves: [ jesting1 ]
db2_db2inst1_db2inst1_SAMPLE-primary-VIP       (ocf::heartbeat:IPaddr2):       Started inwards1
db2_db2inst1_db2inst1_SAMPLE-standby-VIP       (ocf::heartbeat:IPaddr2):       Started jesting1
The following example shows the command syntax and output from running a user-initiated takeover from the standby host sample as the instance owner (see step 1):
[db2inst1@jesting1 ~]$ db2 takeover hadr on db sample
DB20000I  The TAKEOVER HADR ON DATABASE command completed successfully.
The following example shows the command syntax and output from verifying that the primary host has failed over and that the VIPs of each host have switched (see step 2):
 
[root@jesting1 ~]# crm status
Stack: corosync
Current DC: jesting1 (version 2.0.2-1.el8-744a30d655) - partition with quorum
Last updated: Tue Mar 10 13:37:52 2020
Last change: Mon Mar  9 09:58:45 2020 by root via cibadmin on inwards1
     
2 nodes configured
7 resources configured
     
Online: [ inwards1 jesting1 ]
     
Full list of resources:
     
db2_inwards1_eth1      (ocf::heartbeat:db2ethmon):     Started inwards1
db2_jesting1_eth1        (ocf::heartbeat:db2ethmon):     Started jesting1
db2_inwards1_db2inst1_0        (ocf::heartbeat:db2inst):       Started inwards1
db2_jesting1_db2inst1_0  (ocf::heartbeat:db2inst):       Started jesting1
Clone Set: db2_db2inst1_db2inst1_SAMPLE-clone [db2_db2inst1_db2inst1_SAMPLE] (promotable)
     Masters: [ jesting1 ]
     Slaves: [ inwards1 ]
db2_db2inst1_db2inst1_SAMPLE-primary-VIP       (ocf::heartbeat:IPaddr2):       Started jesting1
db2_db2inst1_db2inst1_SAMPLE-standby-VIP       (ocf::heartbeat:IPaddr2):       Started inwards1