Instructs an HADR standby database to take over as the new HADR primary database for the HADR pair. This is a cluster-wide command in a DB2® pureScale® environment, so you can issue it on any member on the standby, including non-replay members.
One of the following authorities:
Instance. The command establishes a database connection if one does not exist, and closes the database connection when the command completes.
>>-TAKEOVER HADR ON--+-DATABASE-+--database-alias---------------> '-DB-------' >--+--------------------------------------+---------------------> '-USER--user-name--+-----------------+-' '-USING--password-' >--+--------------------------------+-------------------------->< '-BY FORCE--+------------------+-' '-PEER WINDOW ONLY-'
You cannot use the PEER WINDOW ONLY option when the synchronization mode is set to ASYNC or SUPERASYNC.
Table 1 and Table 2 show the behavior of the TAKEOVER HADR command when issued on an active standby database for each possible state and option combination. An error message is returned if this command is issued on an inactive standby database.
Standby state | Takeover behavior |
---|---|
Disconnected peer | Takeover fails and an error message is returned. |
Local catchup | Takeover fails and an error message is returned. |
Peer | The primary database and standby database switch
roles. If no failure is encountered during takeover, there is no data loss. However, if failures are encountered during takeover, data loss might occur and the roles of the primary and standby might or might not have been changed. The following is a guideline for handling failures during a takeover in which the primary and standby switch roles:
|
Remote catchup | Non-forced takeover is allowed
in remote catchup state only if one of the following is true:
|
Remote catchup pending | Takeover fails and an error message is returned. |
Standby state | Takeover behavior |
---|---|
Disconnected peer (without the PEER WINDOW ONLY option) | The standby database becomes the primary database,
but there is no assurance of data consistency. Note: A "no transaction
loss" takeover is also possible using the TAKEOVER BY
FORCE command without the PEER WINDOW ONLY option,
that is, unconditional failover, as long as the necessary conditions
hold. Such a failover can be executed even long after the expiration
of the peer window that was in effect when the primary failed.
|
Disconnected peer (with the PEER WINDOW ONLY option) | The standby database becomes the primary
database, and there is a greater assurance of data consistency than
if you did not specify the PEER WINDOW ONLY option.
There are situations in which data loss can still happen:
|
Local catchup | In most cases, takeover fails and an error message is returned. The exception is when primary reintegration is in progress; during the reintegration, forced a takeover is allowed on a standby in local catchup state. |
Peer | The standby database becomes the primary database, but there is no assurance of data consistency. Even with SYNC and NEARSYNC mode, the primary can fall out of peer state and commit more transactions, with the standby still in peer state and not aware of the primary's state change (the primary and standby may not notice network connection breakage at the same time). |
Remote catchup | The standby database becomes the primary database, but there is a risk of data loss. |
Remote catchup pending | The standby database becomes the primary database, but there is a risk of data loss. If log retrieval is in progress (retrieval only happens in remote catchup pending state), retrieval is stopped as part of the takeover process. |
When issuing the TAKEOVER HADR command, the corresponding error codes might be generated: SQL1767N, SQL1769N, or SQL1770N with a reason code of 98. The reason code indicates that there is no installed license for HADR on the server where the command was issued. To correct the problem, install a valid HADR license using the db2licm or install a version of the server that contains a valid HADR license as part of its distribution.
If you have reads on standby enabled, any user application currently connected to the standby is disconnected to allow the takeover to proceed. Depending on the number of readers that are active on the standby, the takeover operation can take slightly longer to complete than it would if there were no readers on the standby. New connections are not allowed during the role switch. Any attempt to connect to the HADR standby during the role switch on takeover receives an error (SQL1776N).
If you are using a high value for hadr_spool_limit, you should consider that if there is a large gap between the log position of the primary and log replay on the standby, which might lead to a longer takeover time because the standby cannot assume the role of the new standby until the replay of the spooled logs finishes.
If you have configured hadr_replay_delay to a non-zero value, you cannot issue the command on that standby (SQL1770N).