Procedure for switching the active and standby databases

Before switching, you must implement a method for switching clients, as described in “Setting up clients to work with the active data server”.

Follow these steps to switch the active and standby databases for a logical connection:

  1. At the Adaptive Server of the active database, ensure that the RepAgent is shut down. Otherwise, use sp_stop_rep_agent to shut down the RepAgent.

  2. At the Replication Server, enter:

    switch active for logical_ds.logical_db
    to data_server.database
    

    data_server.database is the new active database.

    See “Internal switching steps” for information on what Replication Server does when you switch.

  3. To monitor the progress of a switch, you can use the admin logical_status command:

    admin logical_status, logical_ds, logical_db
    

    The Operation in Progress and State of Operation in Progress output columns indicate the switch status.

  4. When the active database switch is complete, you must restart RepAgent for the new active database:

    sp_start_rep_agent dbname
    

NoteIf Replication Server stops in the middle of switching, the switch resumes after you restart Replication Server.


Using a blocking command for switch active

In Replication Server, the wait for switch command is a blocking command. It tells Replication Server to wait until the standby database is ready for operation. You can use this command in a script that switches the active database. The syntax is:

wait for switch for logical_ds.logical_db

Monitoring the switch

You can use admin logical_status to check for replication system problems that prevent the switch from proceeding. Such problems may include a full transaction log for the standby database or a suspended standby DSI. If you cannot resolve the problems, you can abort the switch using the abort switch command.

The Operation in Progress and State of Operation in Progress output columns indicate the switch status.

For example, suppose the admin logical_status command persistently returns one of the following messages in its State of Operation in Progress output column:

Standby has some transactions that have not been applied

or

Inbound Queue has not been completely read by Distributor

These messages may indicate a problem that you cannot resolve, in which case you may choose to abort the switch. You can use admin who commands to obtain more information about the state of the switching operation.

See “Commands for monitoring warm standby applications” for more information.


Aborting a switch

Unless Replication Server has proceeded too far in switching the active and standby databases, you can abort the process by using the abort switch command:

abort switch for logical_ds.logical_db

If the abort switch command cancels the switch active command successfully, you may have to restart the RepAgent for the active database.

You cannot cancel the switch active command after it reaches a certain point. If this is the case, you must wait for the switch active command to complete, then use it again to return to the original active database.