Starting a user-initiated takeover by force

You can initiate the forced takeover of a primary HADR host from the standby host on a Pacemaker-managed Db2 instance. Expect the Pacemaker cluster to reintegrate the old primary as the new standby.

Procedure

  1. As the Db2® instance owner, run a user-initiated takeover from the standby host, using the by force option:
    ./sqllib/bin/db2 takeover hadr on db <database_name> by force
  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:
    [db2inst1@inwards1 ~]$ db2pd -db <database_name> -hadr | grep ROLE
                                    HADR_ROLE = PRIMARY
    New standby:
    [db2inst1@jesting1 ~]$ 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 domain:
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
8 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
The following example shows the command syntax and output from running the user-initiated takeover from the standby host on the cluster (see step 1):
[db2inst1@inwards1 ~]$ db2 takeover hadr on db testdb by force
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: [ 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