Skip to main content

repadm

Replication Agent administrator utility

The Replication Agent administrator utility, repadm, is used to control and retrieve statistics from the Replication Agent process.

repadm -c <command> [-s <svn>] [-u <uid>] [-p <upw>] [-a <agentID>] [-i <int> [<cnt>]] [-h <frq>] 
				[-threadid <threadID>]
Table 1. Commands

Command

Description

addagent <configFileName> -s <replAgentManagerServerName>

Use the replication agent manager that is currently running on the server named <replAgentManagerServerName> to add a replication agent using the settings provided in the configuration file named <configFileName>. This configuration file must exist on the system where the replication agent manager is running.

cancelaction <agentID> [<requestID>] -s <replAgentManagerServerName>

Use the replication agent manager that is currently running on the server named <replAgentManagerServerName> to cancel the action with the specified request ID <requestID> for the replication agent specified by the unique ID <agentID>. If a request ID is not specified, that replication agent's current action is cancelled.

changefilter -x <filterFileName> -a <agentID> -s <replAgentServerName>

Use the filter definition in the file <filterFileName> to change the file filter for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>. This filter file must exist on the system where the repadm utility is running

demoteserver -s <primaryServerName>

Take all required actions to demote the server named <primaryServerName> from the primary server to the secondary server.

deployfilegroups <agentID> <configFileName> -s <replAgentManagerServerName>

Use the replication agent manager that is currently running on the server named <replAgentManagerServerName> to deploy the file groups in the configuration file <configFileName> to the replication agent specified by the unique ID <agentID>. The configuration file must exist on the system where the replication agent manager is running.

exceptionlog

Controls exception logging. This is for V11.5 and later.

exceptionlog=on -a <agentID> -s <replAgentServerName>

Enables exception logging for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

exceptionlog=off -a <agentID> -s <replAgentServerName>

Disables exception logging for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

fnctim=on -a <agentID> -s <replAgentSeverName>

Enables function timing for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

fnctim=off -a <agentID> -s <replAgentServerName>

Disables function timing for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

getactionstatus <agentID> [<requestID>] -s <replAgentManagerServerName>

Use the replication agent manager that is currently running on the server named <replAgentManagerServerName> to get the status of the action with the specified request ID <requestID> for the replication agent specified by the unique ID <agentID>. If a request ID is not specified, the status of the replication agent's current action is returned.

getagentids -s <replAgentServerName>

Lists the replication agent IDs for the server named <replAgentServerName>.

getexceptionlogcount -a <agentID> -s <replAgentServerName>

Gets the current number of records in the exception log for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>. The exit code for this command is one of the following values:

0: No exception log records exist
1: Exception log records exist
2: An error occurred

getfilter -a <agentID> -s <replAgentServerName>

Retrieves the current file filter list for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

getfuncstats -a <agentID> -s <replAgentServerName> [-d]

Retrieves the function statistics for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>. If the -d option is specified, the utility displays delta values instead of cumulative values for the replication statistics.

getlog -s <replAgentServerName> [-showdetails <option>]

Reads the replication exception log entries that are stored on the server named <replAgentServerName>, starting with the first entry. The -showdetails option can be used to show key values and record images for the exception log entries. It can be specified more than once. Supported values are:

all: Shows all available information
currecimg: Shows the current record image on the target server in case of a replication conflict error
keyval: Shows the new key value
oldkey: Shows the old key value
oldrec: Shows the old record image
recimg: Shows the new record image

getlogtail -s <replAgentServerName> [-showdetails <option>]

Reads the replication exception log entries that are stored on the server named <replAgentServerName>, starting with the last entry. The -showdetails option can be used to show key values and record images for the exception log entries. It can be specified more than once. Supported values are:

all: Shows all available information
currecimg: Shows the current record image on the target server in case of a replication conflict error
keyval: Shows the new key value
oldkey: Shows the old key value
oldrec: Shows the old record image
recimg: Shows the new record image

getoldestuncommittedtran -a <agentID> -s <replAgentServerName>

Gets information about the oldest uncommitted transaction for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

getparallelstate -a <agentID> -s <replAgentServerName>

Returns the current parallel replication state of the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

getresyncfiles -a <agentID> -r <resyncID> -s <replAgentServerName>

Retrieves the list of files for the replication resync operation specified by the resync ID <resyncID> for the replication agent specified by the unique ID <agentID>.

getserverrole -s <serverName>

Returns the current role of the server named <serverName>.

getsyncmode -s <serverName>

Returns the current sync mode of the server named <serverName>.

getstate -a <agentID> -s <replAgentServerName>

Returns the current replication state for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

getstats -a <agentID> -s <replAgentServerName> [-d]

Returns the replication statistics for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>. If the -d option is specified, the utility displays delta values instead of cumulative values for the replication statistics.

getthreadnames -a <agentID> -s <replAgentServerName>

Lists the names of the threads of the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

gettranstate -a <agentID> -s <targetServerName>

Returns the transaction commit state of the replication agent specified by the unique ID <agentID> on the target server named <targetServerName>.

isactive -a <agentID> -s <replAgentServerName>

Checks if the replication agent specified by the unique ID <agentID> is active on the server named <replAgentServerName>.

listagents -s <sourceServer>

Lists the replication agents that are registered with the server named <sourceServer>.

listagentfilters -s <sourceServer>

 Lists the replication agent file filters that are registered with the server named <sourceServer>.

listfilter

 Lists all current replication filters

pause -a <agentID> -s <replAgentServerName>

Pauses the Replication Agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

pollactionstatus <agentID> [<requestID>] -s <replAgentManagerServerName>

Uses the replication agent manager that is currently running on the server named <replAgentManagerServerName> to monitor the status of the action specified by the request ID <requestID> for the replication agent specified by the unique ID <agentID>. If a request ID is not specified, the status of the specified replication agent's current action is monitored.

promoteserver -s <secondaryServerName>

Takes all required actions to promote the server named <secondaryServerName> from secondary server to primary server.

purgelog -a <agentID> -s <replAgentServerName>

Purges all entries from the replication exception log on the server named <replAgentServerName> where a replication agent specified by the unique ID <agentID> is currently running.

removeagent <agentID> -s <replAgentManagerServerName>

Uses the replication agent manager that is currently running on the server named <replAgentManagerServerName> to remove the replication agent specified by the unique ID <agentID>.

removeagentstate -a <agentID> -s <replAgentServerName>

Removes the state information for a managed replication agent from the source and target servers.

removefilegroups <agentID> <filegroups> -s <replAgentManagerServerName>

Uses the replication agent manager that is currently running on the server named <replAgentManagerServerName> to remove the specified file groups from the replication agent specified by the unique ID <agentID>. <filegroups> lists one or more file group names separated by a vertical bar. For example: "filegroup1|filegroup2".

removefilter -x <filterFileName> -a <agentID> -s <replAgentServerName>

Removes the file filter that is listed in the XML filter file named <filterFileName> from the replication agent specified by the unique ID <agentID> that is currently running on the server named <repAgentServerName>. The filter file named <filterFileName> must exist on the system where the replication agent is running.

removesyncagent -a <agentID> -s <sourceServerName>

Removes the synchronous replication agent specified by the unique ID <agentID> from the source server named <sourceServerName>.

resetfuncstats -a <agentID> -s <replAgentServerName>

Resets function statistics for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

resetstats -a <agentID> -s <replAgentServerName>

Resets replication statistics for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

resume -a <agentID> -s <replAgentServerName>

Resumes the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

resync -f <fileList> -a <agentID> -s <replAgentServerName> [-w <workDir>]

Resynchronizes the list of source files for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>. The resync filelist file named <fileList> must exist on the system where the repadm utility is running. <workDir> optionally specifies the working directory where the resync operation stores the dump information. If it is not specified, the server data directory is used.

resyncclean -a <agentID> -r <resyncID> -s <replAgentServerName>

Cleans up the resync resources for the resync operation specified by the resync ID <resyncID> for the replication agent specified by the unique ID <agentID>.

resyncstate -a <agentID> -r <resyncID> -s <replAgentServerName>

Checks the state of the resync operation specified by the resync ID <resyncID> for the replication agent specified by the unique ID <agentID>.

setconfig:<option> -a <agentID> -s <replAgentServerName>

 Changes the configuration option <option> for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>. The configuration option takes effect immediately and lasts until the replication agent shuts down.

setserverrole <role> -s <serverName>

 Sets the role of the server named <serverName>. Supported options:

primary: Sets the server as the primary server
secondary: Sets the server as the secondary server

settargetserverwritable

When used with shutdown or syncshutdown option, the replication agent enables write access to the target server.

showlatency -a <agentID> -s <replAgentServerName

Displays the current replication latency for the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>.

shutdown -a <agentID> -s <replAgentServerName> [<options>]

Stops the Replication Agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName>. Supported <options>:

-n: Causes the replication agent to unregister itself from the source server
-settargetserverwritable: Causes the replication agent to enable write access on the target server after the replication agent stops

startagent <agentID> -s <replAgentManagerServerName>

Uses the replication agent manager that is currently running on the server named <replAgentManagerServerName> to start the replication agent specified by the unique ID <agentID>.

stopagentmanager -s <replAgentManagerServerName>

Stops the replication agent manager that is currently running on the server named <replAgentManagerServerName>.

syncshutdown -a <agentID> -s <replAgentServerName> [<options>]

Signals to the replication agent specified by the unique ID <agentID> that is currently running on the server named <replAgentServerName> to apply all the changes that it has read from the source server to the target server and then shut down. Supported <options>:

-n: Causes the replication agent to unregister itself from the source server
-settargetserverwritable: Causes the replication agent to enable write access on the target server after the replication agent stops


Table 2. Options

Option

Description

-a <agentID>

Operate on the replication agent specified by the unique ID <agentID>.

-d

Display delta statistic values instead of cumulative values.

-f <filelist>

A text file containing the names of files to resync.

-h <frq>

Print a description header every <frq> outputs.

-i <int> [<cnt>] 

Pause int seconds for optional cnt times.

-p <upw>

User password.

-r <resyncID>

Replication resync ID.

-s <svn> 

Server name.

-t

Output timestamp with header.

-u <uid>

User name.

-w <workDir>

 Working directory name for replication resync.

-x <filterFileName>

 A file containing a replication XML file filter.



Note

This utility can only connect to the Replication Agent process, replagentNSUP_ERR (454) is reported when connecting to a standard FairCom DB database engine with this utility.

This utility supports the use of an encrypted password file. Encrypted password files keep user IDs and passwords from plain view when the utility is used within a script file. They are created with the ctcmdset utility. The plain text form of the file should be:

; User Id
USERID ADMIN
; User Password
PASSWD <pass>

Use the -1 option to specify the name of the encrypted file. Use the -a option to specify the name of the encrypted file.

In V11.6 and later, the getstate option includes a time column, which can be used to determine the latency with ctreplagent (the name of the FairCom replication agent process).

repadm -c getstate -s FAIRAGENT 

The time column shows how up-to-date replication is relative to the source server's current time. On each transaction commit, the source server calculates how many seconds have passed between the time at which the transaction commit entry was written to the transaction log and it sent that value to the replication agent. The replication agent stores this value in memory and makes it available to the repadm utility.

Table 3. Columns of data that state information outputs

Data

Description

s

Connection status to source server (y | n).

t

Connection status to target server (y | n).

lognum

Current transaction log number.

logpos

Current transaction log position.

state

The environment being processed (local | master | self).

seqno

Function sequence number.

time

Number of seconds between the time the transaction commit entry was written to the transaction log and that value to the replication agent. This is for V11.6 and later.

func

Function by name processed.



Example 1. repadm output showing the time value

The first row is showing that the replication agent is 6 seconds behind. The second row shows 7 seconds behind, and the last 2 rows show that it's current and caught up.

s t   lognum     logpos   state    seqno time func

y y       48   30101431  target  1630145    6 ADDREC

y y       49   12735790  source  1698005    7 ctReplGetNextChange

y y       49   12735790  source  1698009    0 ctReplGetNextChange

y y       49   12735790  source  1698009    0 ctReplGetNextChange


The replication exception log (REPLOGDT.FCS) is a FairCom file that contains a record for each error the Replication Agent has logged. This file can be imported into a SQL database for easier examination. V11.6 and later no longer require exclusive access to a table for import and this can be done while REPLLOGDT.FCS is online.

repadm Replication agent administrator options commands and descriptions

repadmreplication agent administratorcommandsoptionsreplication administrator

The repadm utility now supports an option, -settargetserverwritable, that can be used with the shutdown or syncshutdown commands. This option causes the Replication Agent to connect to the target server and set it writable (READONLY_SERVER NO). This is done at the end of shutting down the Replication Agent.

Note

The call to shut down returns to the repadm utility before this is done, since it is done by the main Replication Agent thread rather than the server thread that initiates the shutdown of the Replication Agent.

Example 2. Replication Agent shutdown command
repadm -c syncshutdown -settargetserverwritable -s FAIRAGENT


The repadm utility now supports an option to indicate if the Replication Agent is operational. Operational means the agent threads are running and are connected to the source and target server as appropriate. This simple point-in-time check is able to detect when Replication Agent threads have exited due to an error and when Replication Agent threads are not connected to their servers. It cannot detect a situation where Replication Agent threads are alive but are in a hung state.

Example 3. repadm command-line usage

The utility outputs a value of y if the agent is operational, p if the agent is paused, and n if the agent is not operational.

repadm -c isactive -s AGENTSERVERNAME


Example 4. Function call usage

ctReplAgentOp() with mode of ctRAOPcheckifactive.

NINT rc;

TEXT stateBuffer[2];

VRLEN bufsize = 2;

rc = ctReplAgentOp(ctRAOPcheckifactive, NULL, 0, stateBuffer, &bufsiz);


When the repadm utility's isactive command is used, the utility now sets the return code to indicate the agent's status as of the last check made by the utility.

Table 4. Status codes

Status code

Description

More status codes may be added in the future.

1

Error checking agent status

2

Agent is operational

3

Agent is paused

4

Agent is not operational



The repadm utility can be used to reset the Replication Agent statistics (counts of passed/failed operations). Use the option repadm -c resetstats.

This is in addition to the existing support for resetting Replication Agent function statistics (repadm -c resetfuncstats).

By default, when the Replication Agent fails to apply a replicated operation to the target server, it writes an entry to the replication exception log for every operation in the transaction where the failure occurred. This makes it possible to see what operations were not applied due to the failure. But this can generate a lot of log entries and may make it difficult to see the failed operations.

To address these issues, we added a Replication Agent configuration option to instruct the agent to only record exception log records for those operations that failed. To use this feature, add the following option to the Replication Agent configuration file, ctreplagent.cfg.

exception_logging errors_only

The repadm utility now supports an option to cause the Replication Agent to finish applying all changes it has read from the source server's transaction logs and then shut down.

The repadm utility's -n option can also be used with this option.

Example 5. Output
C:\> repadm -c syncshutdown -s AGENTSERVERNAME

Requesting replication agent to shut down with the specified options.

Successfully shut down the replication agent. Log copy position=<6,309897979> Last commit position=<6,309888349> Log read position=<6,309897979> Transaction ID=808025

Note

If the Replication Agent was not able to connect to the target server before it is shut down, it reports zeros for the log positions and transaction ID.