Switching HADR roles with shadow tables

To switch HADR roles for a database that contains shadow tables, plan a takeover that performs the appropriate actions to ensure that your shadow tables are available and current on the new HADR primary server.

Before you begin

Procedure

To switch HADR roles for a database that contains shadow tables:

  1. Log in to the access-server-host as cdc-user.

    1. Stop replication on the primary server by using the following InfoSphere CDC system command:
      dmendreplication -I cdc_inst_name -c -s cdc_subscription_name 
      Use the -c option to wait for all in-progress operations to finish and end the replication in a controlled manner. Avoid using the immediate end type because you can end up with unreliable metadata.
    2. Stop the InfoSphere CDC instance on the primary server by using the following InfoSphere CDC system command:
      dmshutdown -I cdc-instance-name 
    3. Verify that the subscription and instance is stopped by checking that the dmts64 or dmts32 process is not running.
  2. Switch the HADR primary to one of the standby servers by issuing the TAKEOVER HADR command on the standby server (the principal standby if you have auxiliary standbys) as shown in the following example
    TAKEOVER HADR ON DB db-name
  3. Confirm that the old standby has now the PRIMARY role with the db2pd command or the MON_GET_HADR table function.
  4. Restore the most recent version of the InfoSphere CDC configuration metadata from the old primary (by taking a backup using dmbackupmd command) to the new primary.
  5. Start the InfoSphere CDC instance on the new HADR primary server. For more information, see Starting InfoSphere CDC for Db2®.
  6. Update the InfoSphere CDC instance with the new hostname and IP address by using the InfoSphere CDC Management Console:
    1. Log in to the InfoSphere CDC Management Console as access-server-user in the access-server-host.
    2. Navigate to the Access Manager tab.
    3. Right click on the datastore and select Properties.
    4. Update the Host Name field and click the Ping button.
    5. Click the OK button.
    6. From the InfoSphere CDC Management Console, update the subscriptions:
      1. Navigate to the Configuration tab and connect to the datastore. You should be able to see the subscription for shadow tables.
      2. Right click on the datastore and select Properties.
      3. Click Update Related Subscriptions button. The Update Related Subscriptions popup window should appear.
      4. Ensure the previous hostname is selected, and click the OK button.
      5. In the next Update Related Subscriptions popup window that appears, click the Update button.
      6. In the next Update Related Subscriptions popup window that appears, click the OK button. You will be automatically logged out of the InfoSphere CDC Management Console.
      7. Log in to the InfoSphere CDC Management Console again, and check that the datastore and related subscriptions have the expected values.
    Note: If you are already using a virtual IP (VIP) for client connections instead of automatic client reroute (ACR), for example, then you can make a database role switch or a failover transparent to InfoSphere CDC Access Server by using that VIP. Because the datastore connections can be configured using this VIP instead of using the actual HADR host names or IP addresses, no configuration changes are required after the standby takes over the primary role. However, VIP floating is limited to a single IP subnet, so it is suitable for data center HA purposes and not for remote DR sites.

    Using just a VIP and Db2 integrated HA does not fully automate the CDC with HADR architecture, because the required CDC failover tasks still require manual intervention.

  7. Clear the staging store on the new HADR primary server by using the following InfoSphere CDC system command:
    dmclearstagingstore -I cdc-instance-name
  8. Start replication on the new HADR primary server by using the following InfoSphere CDC system command:
    dmstartmirror -I cdc-instance-name -c -s cdc-subscription-name  
  9. From the InfoSphere CDC Management Console, verify that mirroring for the subscription started by selecting Configuration > Subscriptions. The subscription should be in mirroring state.