Determining how to initialize the standby database

You initialize the standby database with data from the active database. To do this, use these Adaptive Server commands and utilities:

See the Adaptive Server Enterprise Reference Manual: Commands.

Replication Server writes an “enable replication” marker into the active database transaction log when you add the standby database using Sybase Central or rs_init. Adaptive Server writes a dump marker into the active database transaction log when you perform a dump operation—either a dump database or a dump transaction.

If you do not suspend transaction processing during initialization:

If you suspend transaction processing during initialization:

The target database cannot be materialized with dump or load if the database used is the master database. You may use other methodologies such as bcp where the data can be manipulated to resolve inconsistencies.

Cross-platform dump and load

If you use cross-platform dump and load to initialize a standby database with a RepAgent:

  1. On the active database:

    1. Stop the RepAgent with sp_stop_rep_agent database.

    2. Remove the secondary truncation point with dbcc settrunc(‘ltm’, ‘ignore’).

    3. Set the database in single-user mode in Adaptive Server:

      sp_dboption database_name, ‘single user’, true
      
    4. Checkpoint the database:

      checkpoint
      
    5. Dump the database transaction log by executing in Adaptive Server:

      dump tran database_name with truncate_only
      go
      
      
    6. Obtain a dump of the database. See “Dumping and loading databases across platforms,” in Chapter 11 “Developing a Backup and Recovery Plan” in the Adaptive Server Enterprise System Administration Guide Volume 2.

  2. On the standby database:

    1. Load the dump you obtained from the standby database. See “Dumping and loading databases across platforms,” in Chapter 11 “Developing a Backup and Recovery Plan” in the Adaptive Server Enterprise System Administration Guide Volume 2.

      Sybase recommends running sp_post_xpload even if the endian types of the platforms are not different.

    2. Dump the transaction log to delete the log records that sp_post_xpload creates:

      dump tran database_name with truncate_only
      go
      
      
    3. Execute the Adaptive Server sp_indsuspect system procedure to check user tables for indexes marked as suspect.

    4. Rebuild suspect indexes if required. If there is a change in characterset or sort order, you must execute sp_indsuspect and rebuild indexes again until sp_indsuspect does not show any tables with suspect indexes.

    5. Execute dbcc settrunc ('ltm', 'valid') to restore the secondary truncation point in the database log followed by rs_zeroltm to reset the database locater value to zero. Executing these commands allows RepAgent to start at the secondary truncation point.

    6. Start RepAgent with sp_start_rep_agent database.

Table 3-4 summarizes each of the initialization methods and the role of these markers.

Table 3-4: Issues in initializing the standby database

Issue

Use dump and load with “dump marker”

Use dump and load without “dump marker”

Use bcp

Use mount

Working with client applications.

Use if you can not suspend transaction processing for client applications.

Use if you can suspend transaction processing for client applications.

Use if you can suspend transaction processing for client applications.

When does Replication Server begin replicating into the standby database?

Replication Server starts replicating into the standby database from the first dump marker after the enable replication marker.

Replication Server starts replicating into the standby database from the enable replication marker.

Replication Server starts replicating into the standby database from the enable replication marker.

Creating maintenance user login names and making sure all user IDs match.

Add the login name for the standby database maintenance user in both the active Adaptive Server and the standby Adaptive Server, and ensure that the server user’s IDs match.

(You create login names in the active Adaptive Server because using dump and load to initialize the standby database with data from the active database overrides any previous contents of the standby database with the contents of the active database.)

When you add the standby database, Sybase Central or rs_init adds the maintenance user login name and user in the standby Adaptive Server and the standby database.

Add the login name for the standby database maintenance user in both the active and standby Adaptive Servers. Ensure that the server user’s IDs match. (You create login names in the active Adaptive Server because using mount to initialize the standby database with data from the active database overrides any previous contents of the standby database with the contents of the active database.)

Initializing standby database.

Use dump and load to transfer data from the active database to the standby database.

You can use database dumps and/or transaction dumps.

Use bcp to copy each replicated table from the active database to the standby database.

Use quiesce database ... to manifest_file and mount database to transfer data from the active database to the standby database.

Active database connection state.

The connection to the active database does not change.

Replication Server suspends the connection to the active database.

Replication Server suspends the connection to the active database.

Resuming connections.

Resume connection to the standby database.

Resume connections to the active and standby databases; resume transaction processing in the active database.

Resume connections to the active and standby database; resume transaction processing in the active database.

If you do not suspend transaction processing

If you do not suspend transaction processing for the active database while initializing the standby database, choose the “dump marker” option when you add the standby database. Then initialize the standby database by using the dump and load commands.

Replication Server starts replicating into the standby database from the first dump marker after the enable replication marker in the transaction log of the active database.

In Figure 3-2, transaction T1, executed after you added the standby database, appears after the enable replication marker in the log. T1 is included in dumps, so it is present in the standby database after you have loaded the dumps. Replication Server does not need to replicate it into the standby database.

Figure 3-2: Using dump and load with dump marker

Figure 3-2 illustrates the use of dump and load with dump marker through an Active database transaction log. A transaction T 1, executed after adding the standby database, appears after the enable replication marker in the log. T 1 is included in dumps, and is loaded in the standby database after loading the dumps. Replication Server does not need to replicate it into the standby database. Transactions can be executed in the active database between the time the enable replication marker is written and the time the data in the active database is dumped.

Transactions can be executed in the active database between the time the enable replication marker is written and the time the data in the active database is dumped.

You can load the last full database dump and any subsequent transaction dumps into the standby database until both markers have been received and the standby database is ready for operation. Then, optionally, you can use a final transaction dump of the active database to bring the standby database up to date. Any transactions not included in dumps will be replicated.

Replication Server does not replicate transactions from the active to the standby database until it has received both the enable replication marker and the first subsequent dump marker. After receiving both markers, Replication Server starts executing transactions in the standby database.

See Table 3-4 for more information about this method.

If you suspend transaction processing

If you suspend transaction processing for the active database while initializing the standby database, do not choose the “dump marker” option when you add the standby database. You can initialize the standby database by using the dump and load commands, by using bcp, or by using mount.

Replication Server starts replicating into the standby database from the enable replication marker in the transaction log of the active database. No transactions occur after the enable replication marker, because client applications are suspended.

Figure 3-3: Using dump and load without dump marker, or using bcp

Figure 3-3 shows an Active database transaction log. It illustrates the use of dump and load without dump marker, or using bcp. No transactions are executed in the active database between the time the enable replication marker is written and the time the data in the active database is dumped using the dump command, or copied using bcp or mount.

As shown in Figure 3-3, no transactions are executed in the active database between the time the enable replication marker is written and the time the data in the active database is dumped using the dump command, or copied using bcp or mount.

You can load the last full database dump or the last set of replicated tables copied with bcp into the standby database until the standby database receives the enable replication marker.

After receiving this marker, Replication Server starts executing transactions in the standby database.