Show TOC

sp_start_rep_agentLocate this document in the navigation structure

Starts a RepAgent thread for the specified database.

Syntax
sp_start_rep_agent <dbname>[, {'recovery' | 'recovery_foreground’ | 'resync' | 'resync purge' 
																		| 'resync init'} [, '<connect_dataserver>', 
              '<connect_database>'[, '<repserver_name>', <repserver_username>', 
             '<repserver_password>']]]
Parameters
dbname

The name of the database for which you want to start a RepAgent.

recovery

Starts the RepAgent in recovery mode, which is used to initiate recovery actions. Recovery mode is used to rebuild queues when queues are lost.

You can also specify the Replication Server name, user name, and password in recovery mode. Specify these parameters to override <sysattributes> settings.

recovery_foreground

recovery_foreground has the same function as recovery. However, it displays the recovery progress information on screen instead of in the Adaptive Server error log. The recovery is complete once the recovery progress information display ends and the command prompt displays.

resync

Sends the resync database marker without any option when there is no change to the truncation point and the expectation is that the RepAgent should continue processing the transaction log from the last point that it processed.

resync purge

Sends the resync database marker with the purge option to instruct Replication Server to purge all open transactions from the inbound queue, and reset duplicates detection, before receiving any new inbound transactions.

resync init

Sends the resync database marker with the init option to instruct Replication Server to purge all open transactions from the inbound queue, reset duplicate detection, and suspend the outbound DSI.

connect_dataserver

The name of the data server used to recover offline logs.

connect_database

The name of the database used to recover offline logs.

repserver_name

The name of the Replication Server to which RepAgent connects.

repserver_user_name

The user name that RepAgent uses to connect to Replication Server.

repserver_password

The password that RepAgent uses to connect to Replication Server.

Examples
Example 1

Starts an integrated RepAgent for the <pubs2> database. RepAgent connects to the Replication Server specified in sp_config_rep_agent. It starts scanning the transaction log and sends formatted LTL commands to Replication Server.

sp_start_rep_agent pubs2 
Example 2

Starts RepAgent in recovery mode for the <pdb2> database connected to the <svr2> data server.

sp_start_rep_agent pubs2 for_recovery, svr2, pdb2
Example 3
Configures RepAgent to print the recovery of database <db2> to the client:
sp_start_rep_agent db2, recovery_foreground, ds, db1
RepAgent(5). Starting recovery, processing log records 
   between (1018, 0) and (2355, 2).
RepAgent(5). Processed 1000 log records.
RepAgent(5). Processed 2000 log records.
RepAgent(5). Processed 3000 log records.
RepAgent(5). Processed 4000 log records.
RepAgent(5). Processed 5000 log records.
RepAgent(5). Processed 6000 log records.
RepAgent(5). Processed 7000 log records.
RepAgent(5). Processed 8000 log records.
RepAgent(5). Processed 9000 log records.
RepAgent(5). Processed 10000 log records.
RepAgent(5). Processed 11000 log records.
RepAgent(5). Processed 12000 log records.
RepAgent(5). Processed 13000 log records.
RepAgent(5). Processed 14000 log records.
RepAgent(5). Processed 15000 log records.
RepAgent(5). Processed 16000 log records.
RepAgent(5). Processed 17000 log records.
RepAgent(5). Processed 18000 log records.
RepAgent(5). Processed 19000 log records.
RepAgent(5). Processed 20000 log records.
RepAgent(5). Processed 20084 log records, recovery
   complete.
Replication Agent thread is started for database 'db2'.
(return status = 0)
Usage
  • Use sp_start_rep_agent with RepAgent-enabled databases.

  • Use the sp_start_rep_agent command to start up RepAgent after you have enabled it with sp_config_rep_agent. Once you have started RepAgent with sp_start_rep_agent, it will automatically start up after the data server is recovered during server startup.

  • Autostart is disabled after you have used sp_stop_rep_agent to shut down RepAgent. Reenable it using sp_start_rep_agent.

  • For offline recovery, archived transaction logs may be dumped to a temporary recovery database. You can then transfer records in the transaction log of the temporary recovery database to the replicate database. Execute sp_start_rep_agent with either recovery or recovery_foreground, using the temporary data server and database names, to scan the temporary transaction log.

    In recovery, when the RepAgent has completed scanning the transaction log, RepAgent shuts down. After the next transaction dump has been loaded, restart the RepAgent by executing sp_start_rep_agent with the options specified earlier.

Permissions

sp_start_rep_agent requires “sa” or “dbo” permission or replication_role.