Changing replicate databases to primary databases

Each primary database must have a Replication Agent that scans the database log and transfers data to the Replication Server for distribution to replicate databases. If you want to change an Adaptive Server database that is designated as replicate-only to be a source of replicated functions or to contain primary data, you must enable the RepAgent thread for the database by following these steps:

At the Replication Server

  1. Create a RepAgent user so that RepAgent can log in to Replication Server.

    Use the following create user command, where ra_user_name is the name of the RepAgent user and ra_password is the RepAgent’s password:

    create user ra_user_name
    set password {ra_password | null}
    

    Grant this user connect source permission, using the grant command:

    grant connect source to ra_user_name
    

    If the Replication Server already manages a primary database, you can use the “RepAgent user” that already exists for the new primary database.

  2. Execute the alter connection command using the log transfer on option:

    alter connection to data_server.database
    set log transfer to 'on'
    

At the Adaptive Server

  1. If the name of the local Adaptive Server has not yet been defined, you must define it with the following command, where lname is Adaptive Server’s name:

    sp_addserver lname, local
    
  2. If RepAgent threads have not been enabled for the Adaptive Server, you must enable them:

    sp_configure 'enable rep agent threads'
    
  3. Configure RepAgent for the database with the sp_config_rep_agent system procedure:

    sp_config_rep_agent dbname, 'enable', 'rs_name',
        'rs_user_name', 'rs_password'
    

    Refer to Chapter 5, “Managing RepAgent and Supporting Adaptive Server,” for detailed instruction on configuring RepAgent.

    NoteThe values for rs_user_name and rs_password configured at the Adaptive Server must be the same as for ra_user_name and ra_password created at the Replication Server in step 1.

  4. Create the rs_marker stored procedure and set its replicate status to “true”, using the sp_setreplicate system procedure.

    You can find the rs_marker stored procedure in the file rs_install_primary.sql or rsinssys.sql in the scripts directory of the Sybase release directory.

    See “Creating the rs_marker stored procedure” for details.

  5. Start RepAgent:

    sp_start_rep_agent dbname