Switching database roles in high availability disaster recovery (HADR)
You can initiate a takeover operation on a high availability disaster recovery (HADR) standby to switch the roles of the primary and standby databases.
Before you begin
- peer state
- remote catchup state, when the synchronization mode is SUPERASYNC
- assisted remote catchup state (Db2 pureScale environments only)
If the log gap between the primary and standby databases is too big, then the takeover operation can run too long and possibly time-out.
About this task
The TAKEOVER HADR command can only be issued on the standby database. If the primary database is not connected to the standby database when the command is issued, the takeover operation fails. In Db2 pureScale environments, you can issue the command from any member in the standby cluster, including non-replay members.
- New connections are rejected, open transactions are rolled back, and all remaining logs are shipped to the standby.
- The primary changes to the standby role, and log receiving and replay is started.
- After it has been confirmed that the old primary is now in the standby role, the standby changes its role to primary.
- Log receiving is stopped after the end of logs. This ensures no data loss.
- All received logs are replayed.
- The new primary database is opened for client connections.
Procedure
To switch the HADR database roles:
- Use the CLP to initiate a takeover operation on the standby database by issuing the TAKEOVER HADR command without the BY FORCE option on the standby database.
- Call the db2HADRTakeover application programming interface (API) from an application.
- Open the task assistant for the TAKEOVER HADR command in IBM® Data Studio.
Example
TAKEOVER HADR ON DB LEAFS
A log full error is slightly more likely to occur immediately following a takeover operation. To limit the possibility of such an error, an asynchronous buffer pool flush is automatically started at the end of each takeover. The likelihood of a log full error decreases as the asynchronous buffer pool flush progresses. Additionally, if your configuration provides a sufficient amount of active log space, a log full error is even more unlikely. If a log full error does occur, the current transaction is aborted and rolled back.