Initializing Mirror Replication Agent

Mirror Replication Agent uses the native transaction log maintained by the primary database to obtain transactions. To support replication, Mirror Replication Agent creates some objects in the primary database.

NoteBefore you initialize a Mirror Replication Agent, the primary database must be quiesced. The procedure for initializing Mirror Replication Agent includes that quiesce.

Specifying the object name prefix

Before you create the Mirror Replication Agent objects, you can specify the object name prefix string to be used to name the objects. You can set this prefix string to avoid conflicts with the names of existing database objects in your primary database.

The value of the pdb_xlog_prefix parameter is the prefix string used in all Mirror Replication Agent object names. Use the ra_config command to change the value of the pdb_xlog_prefix parameter.

NoteMirror Replication Agent uses the value of pdb_xlog_prefix to find its objects in the primary database. If you change the value of pdb_xlog_prefix after you initialize Mirror Replication Agent, Mirror Replication Agent is unable to find the objects that use the old prefix.

NoteMirror Replication Agent requires you to perform specific setup tasks at the primary database before you can initialize Mirror Replication Agent. See the Mirror Replication Agent Primary Database Guide to verify that the required setup tasks have been performed for your primary database.

StepsTo initialize a Mirror Replication Agent

  1. Log in to the Mirror Replication Agent administration port.

  2. To define a prefix that uniquely identifies the Mirror Replication Agent transaction log you are creating, use the following command:

    ra_config pdb_xlog_prefix, string
    

    Here, string is a character string of one to three characters that is used as a prefix for all names of the Mirror Replication Agent objects created in the primary database.

    NoteThe default value of the pdb_xlog_prefix parameter is ra_. Unless this string poses a conflict with existing database object names in your primary database, you should use the default value.

  3. To initialize the Mirror Replication Agent, use the following command:

    pdb_init
    

    NoteThere are two initialization procedures for Microsoft SQL Server: first-time initialization and subsequent initialization. For information on both procedures, see the Mirror Replication Agent Primary Database Guide.

    When you invoke the pdb_init command, Mirror Replication Agent does the following:

    • Checks the primary database for compatible settings.

    • Generates a SQL script that is run in the primary database. This script creates the Mirror Replication Agent objects in the primary database.

    NoteMirror Replication Agent must be initialized before any objects can be marked for replication in the primary database.

  4. To verify the correct initialization for the primary database, invoke the pdb_init command with the move_truncpt keyword, which sets the truncation point to the end of the primary database transaction log:

    pdb_init move_truncpt
    go
    

    A message should indicate that the procedure was successful.

  5. Quiesce the primary database. See “Quiesce the primary database” for details.

  6. The ra_init command initializes the Mirror Replication Agent system database by reading schema information and transaction log location information from the primary Microsoft SQL Server database. If this is a production setup, this step should coincide with creating the dump, copy, or data that is used to materialize the standby database.

    To initialize the Mirror Replication Agent to read schema and transaction log location information from the primary Microsoft SQL Server database, issue the ra_init command:

    ra_initgo
    

    A message appears indicting that the procedure was successful.

    The ra_init command also causes pdb_automark_tables and pdb_auto_create_repdefs settings to take effect.

    WARNING! 

    For Oracle and Microsoft SQL Server: The default value for the pdb_auto_create_repdefs configuration property is true, which will cause a replication definition to be created for each table that is marked for replication during processing of the ra_init command. If you have thousands of tables, this may result in significant additional execution time. To avoid this additional execution time, set the pdb_auto_create_repdefs configuration property to false before invoking the ra_init command. When ra_init execution completes and before replicating, execute the rs_create_repdef all command to create your replication definitions.

    For ASE: While the database may be marked for replication, individual tables are not marked, so individual replication definitions are not created when the ra_init command is executed, regardless of the setting of the pdb_auto_create_repdefs configuration property.

  7. Initialize the Mirror Replication Agent instance:

    ra_init
    
  8. Release the quiesce hold on the primary database:

  9. For Microsoft SQL Server: Change the primary database permission to READ_WRITE:

    alter database primary set READ_WRITE;
    

    NoteYou must have exclusive access to the primary database to change the state or file group to READ_ONLY or READ_WRITE.

  10. To verify that the Mirror Replication Agent was initialized and that its objects were created in the primary database, use the following command:

    ra_helpsysinfo
    

    When you invoke the ra_helpsysinfo command, Mirror Replication Agent returns a list of the transaction log base objects in the primary database if initialization completed successfully. If no information is returned, the transaction log does not exist in the primary database.

When the Mirror Replication Agent is initialized and both primary database and Replication Server connections are defined correctly, you can put the Mirror Replication Agent instance in Replicating state. See “Starting Mirror Replication Agent” for more information about putting the Mirror Replication Agent in Replicating state.