DB2 Version 9.7 for Linux, UNIX, and Windows

Switching database roles in high availability disaster recovery (HADR)

During high availability disaster recovery (HADR), use the TAKEOVER HADR command to switch the roles of the primary and standby databases.

About this task

Procedure

To switch the HADR database roles:

  1. Use the CLP to initiate a takeover operation on the standby database, issue the TAKEOVER HADR command without the BY FORCE option on the standby database.
    In the following example, the takeover operation takes place on the standby database LEAFS:
    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.

    Note: Issuing the TAKEOVER HADR command without the BY FORCE option will cause any applications currently connected to the HADR primary database to be forced off. This action is designed to work in coordination with automatic client reroute to assist in rerouting clients to the new HADR primary database after a role switch. However, if the forcing off of applications from the primary would be disruptive in your environment, you might want to implement your own procedure to shut down such applications prior to performing a role switch, and then restart them with the new HADR primary database as their target after the role switch is completed.
  2. Call the db2HADRTakeover application programming interface (API) from an application.
  3. Open the task assistant for the TAKEOVER HADR command in IBM® Data Studio.
  4. From the Control Center, expand the object tree until you find the database for which you want to manage HADR. Right-click the database and click High Availability Disaster Recovery > Manage in the pop-up menu. The Manage High Availability Disaster Recovery window opens.
    1. Ensure that the databases are in peer state
    2. Click Takeover HADR. The Takeover HADR window opens.
    3. Select that you want to switch the database roles.
    4. If both databases in the HADR pair have been started as standby databases, select one of the databases to take over as the primary database.
    5. Click OK. The window closes. A progress indicator might open to indicate when the command is running. When it completes, you will get a notification indicating whether or not it is successful.
    6. Refresh the Manage High Availability Disaster Recovery window to ensure that the databases have switched roles.
    7. If you are not using the automatic client reroute feature, redirect client applications to the new primary database.

      Additional information is provided through the contextual help facility within the Control Center.