Examples: Takeover in a multiple HADR standby setup
- A principal standby takes over gracefully (role switch)
- An auxiliary standby takes over by force (failover)
- An auxiliary standby takes over by force (failover) in a SA MP or Pacemaker environment
- a primary database (host1)
- a principal standby (host2)
- two auxiliary standbys (host3 and host4)
Configuration parameter | Host1 | Host2 | Host3 | Host4 |
---|---|---|---|---|
hadr_target_list | host2:40|host3:41|host4:42 | host1:10|host3:41|host4:42 | host2:40|host1:10|host4:42 | host2:40|host1:10|host3:41 |
hadr_remote_host | host2 | host1 | host1 | host1 |
hadr_remote_svc | 40 | 10 | 10 | 10 |
hadr_remote_inst | dbinst2 | dbinst1 | dbinst1 | dbinst1 |
hadr_local_host | host1 | host2 | host3 | host4 |
hadr_local_svc | 10 | 40 | 41 | 42 |
Configured hadr_syncmode (Refers to the explicitly set synchronization mode, which is used if the database becomes a primary) |
SYNC | SYNC | SUPERASYNC | SUPERASYNC |
Effective hadr_syncmode (Refers to the synchronization mode that is used if the database is currently a standby) |
n/a | SYNC | SUPERASYNC | SUPERASYNC |
A principal standby takes over gracefully (role switch)
DB2 TAKEOVER HADR ON DB hadr_db
Configuration parameter | Host1 | Host2 | Host3 | Host4 |
---|---|---|---|---|
hadr_target_list | host2:40|host3:41|host4:42 | host1:10|host3:41|host4:42 | host2:40|host1:10|host4:42 | host2:40|host1:10|host3:41 |
hadr_remote_host | host2 | host1 | host2 | host2 |
hadr_remote_svc | 40 | 10 | 40 | 40 |
hadr_remote_inst | dbinst2 | dbinst1 | dbinst2 | dbinst2 |
hadr_local_host | host1 | host2 | host3 | host4 |
hadr_local_svc | 10 | 40 | 41 | 42 |
Configured hadr_syncmode | SYNC | SYNC | SUPERASYNC | SUPERASYNC |
Effective hadr_syncmode | SYNC | n/a | SUPERASYNC | SUPERASYNC |
- Because host2 already has its hadr_remote_host and hadr_remote_svc configuration parameters pointing at its principal standby, host1, these values are not updated on host2.
- Because host1 already has its hadr_remote_host and hadr_remote_svc configuration parameters pointing at the new primary, these values are not updated on host1.
- Because host1's operational synchronization mode is SYNC and host3 and host4's operational synchronization modes are SUPERASYNC, there is no change for the effective synchronization mode.
An auxiliary standby takes over by force (failover)
db2pd -hadr -db hadr_db | grep STANDBY_LOG_FILE,PAGE,POS
DB2 TAKEOVER HADR ON DB hadr_db BY FORCE
Configuration parameter | Host1 (unavailable) |
Host2 | Host3 | Host4 |
---|---|---|---|---|
hadr_target_list | host2:40|host3:41|host4:42 | host1:10|host3:41|host4:42 | host2:40|host1:10|host4:42 | host2:40|host1:10|host3:41 |
hadr_remote_host | host2 | host3 | host2 | host3 |
hadr_remote_svc | 40 | 41 | 40 | 41 |
hadr_remote_inst | dbinst2 | dbinst3 | dbinst2 | dbinst3 |
hadr_local_host | host1 | host2 | host3 | host4 |
hadr_local_svc | 10 | 40 | 41 | 42 |
Configured hadr_syncmode | SYNC | SYNC | SUPERASYNC | SUPERASYNC |
Effective hadr_syncmode | n/a | SUPERASYNC | n/a | SUPERASYNC |
DB2 BACKUP DB hadr_db
DB2 RESTORE DB hadr_db
DB2 START HADR ON DB hadr_db AS STANDBY
As is shown in Table 4, host1 is reconfigured.
Configuration parameter | Host1 | Host2 | Host3 | Host4 |
---|---|---|---|---|
hadr_target_list | host2:40|host3:41|host4:42 | host1:10|host3:41|host4:42 | host2:40|host1:10|host4:42 | host2:40|host1:10|host3:41 |
hadr_remote_host | host3 | host3 | host2 | host3 |
hadr_remote_svc | 41 | 41 | 40 | 41 |
hadr_remote_inst | dbinst3 | dbinst3 | dbinst2 | dbinst3 |
hadr_local_host | host1 | host2 | host3 | host4 |
hadr_local_svc | 10 | 40 | 41 | 42 |
Configured hadr_syncmode | SYNC | SYNC | SUPERASYNC | SUPERASYNC |
Effective hadr_syncmode | SUPERASYNC | SUPERASYNC | n/a | SUPERASYNC |
If the DBA wants to make host1 the primary again, then all that is required is a failback, which will restore the original configuration shown in Table 1.
An auxiliary standby takes over by force (failover) in a SA MP or Pacemaker environment
This example is similar to the previous one, but HADR has been deployed with IBM® Tivoli® System Automation for Multiplatforms (SA MP) to automate failover.
A power failure in City A results in the principal standby (host2) becoming unavailable. Following that, there is an outage on the primary (host1). Normally, the cluster manager would automatically fail over to the principal standby (host2), but the power outage means that one of the auxiliary standbys needs to be the takeover target. Failover cannot be automated to auxiliary standbys, so the DBA must do it manually while keeping host1 offline to eliminate the possibility that the old primary will restart if a client connects to it.
db2pd -hadr -db hadr_db | grep 'STANDBY_LOG_FILE,PAGE,POS'
The DBA
determines that host3 is the most up to date and picks that host as the new primary. DB2 TAKEOVER HADR ON DB hadr_db BY FORCE
Configuration parameter | Host1 (unavailable) |
Host2 | Host3 | Host4 |
---|---|---|---|---|
hadr_target_list | host2:40|host3:41|host4:42 | host1:10|host3:41|host4:42 | host2:40|host1:10|host4:42 | host2:40|host1:10|host3:41 |
hadr_remote_host | host2 | host3 | host2 | host3 |
hadr_remote_svc | 40 | 41 | 40 | 41 |
hadr_remote_inst | dbinst2 | dbinst3 | dbinst2 | dbinst3 |
hadr_local_host | host1 | host2 | host3 | host4 |
hadr_local_svc | 10 | 40 | 41 | 42 |
Configured hadr_syncmode | SYNC | SYNC | SUPERASYNC | SUPERASYNC |
Effective hadr_syncmode | n/a | SUPERASYNC | n/a | SUPERASYNC |
- Disable SA MP on host1
and host2 (for SA MP only) by
running:
db2haicu -disable
- Deactivate the database on host1 and host2 by issuing the following command on both
hosts:
DB2 DEACTIVATE DB hadr_db
- Stop HADR on host1 and host2 to disable automation between them by
running:
DB2 STOP HADR ON DB hadr_db
- Drop the databases on host1 and host2 by running:
DB2 DROP DB hadr_db
- Backup the new primary database on host3 online by
running:
DB2 BACKUP DB hadr_db online
- Copy the backup image to both host1 and host2 using the scp command.
- Restore the
hadr_db
database using the backup image on host1 and host2 by running:DB2 RESTORE DB hadr_db
- Reconfigure the restored database on each host by running the following command:On host1:
DB2 "UPDATE DB CFG FOR hadr_db USING HADR_TARGET_LIST host2:40|host3:41|host4:42 HADR_REMOTE_HOST host3 HADR_REMOTE_SVC 30 HADR_LOCAL_HOST host1 HADR_LOCAL_SVC 10 HADR_SYNCMODE sync HADR_REMOTE_INST dbinst3"
On host2:DB2 "UPDATE DB CFG FOR hadr_db USING HADR_TARGET_LIST host1:10|host3:41|host4:42 HADR_REMOTE_HOST host3 HADR_REMOTE_SVC 41 HADR_LOCAL_HOST host2 HADR_LOCAL_SVC 40 HADR_SYNCMODE sync HADR_REMOTE_INST dbinst3"
- Start HADR on host1 and host2 to reintegrate them as standbys by
running:
DB2 START HADR ON DB hadr_db AS STANDBY
DB2 TAKEOVER HADR ON DB hadr_db