Recovering from a Failure on the Active Database

This section describes how to perform a failover to the standby database, after a failure on the active database or server. Included is how to rebuild the previous active database from a standby database.

This tutorial uses the pre-defined DSNs repdb1_1121 and repdb2_1121 shipped with TimesTen 11.2.1. The hostnames of the two machines are stacb12 and stach17. repdb1_1121 was the active database on stacb12, and repdb2_1121 on stach17 will be converted to become the new active database.

1. Stop the replication agent on the failed database
a. Stop the replication agent on the failed database, if it has not already been stopped. Log in to server 1 (stacb12) as the instance administrator, use the ttAdmin utility to stop replication agent on repdb1_1121.
   
  ttadmin -repstop repdb1_1121
   
 
2. Set the state of the standby database to active
a. Using ttIsql, connect to the database repdb2_1121 as the replication administrator adm.
   
  ttisql "dsn=repdb2_1121;uid=adm"
 
b. Use the built-in procedure ttRepStateSet to designate the current database as the new active database in the active standby pair. Then verify the current replication state by calling the built-in procedure ttRepStateGet.
   
  call ttrepstateset('active');
call ttrepstateget;
   
 
   
  Once the database has entered the active state, it has been converted to an active database. Applications that were previously connected to the failed database can now be diverted to the new active database. See the section on Replication failover and recovery for more information.
3. Mark the previous active database as failed
a. Use the procedure ttRepStateSave to register the former active database as failed.
   
  call ttrepstatesave ('failed','repdb1_1121','stacb12');
4. Destroy the failed database
a. Log in as the instance administrator on server 1 (stacb12), use the ttDestroy utility to remove the failed database repdb1_1121.
   
  ttdestroy repdb1_1121
5. Duplicate the new active database to create a new standby database
a. Use the utility ttRepAdmin to create the standby database by duplicating from the new active database.
   
  ttrepadmin -duplicate -from repdb2_1121 -host "stach17" -uid adm -pwd adm "dsn=repdb1_1121"
6. Start the Replication Agent on the Standby Database
a. Using ttIsql, connect to repdb1_1121 as the replication administrator adm. Call the built-in procedure ttRepStart to start the replication agent.
   
  ttisql "dsn=repdb1_1121;uid=adm"

call ttrepstart;
   
b. Verify that the standby database has entered the standby state by using the ttRepStateGet built-in procedure.
   
  call ttrepstateget;
   
 


Once the standby database has entered the 'standby' state, the configuration of an active standby pair is completed. Changes to the data in the active database will be automatically replicated to the standby database.