c-treeRTG for isCOBOL : Replication Agent : Usage and configuration
Usage and configuration
Transaction logging required
The c-tree replication feature relies on a transaction log based facility. Your files must be under transaction control to take advantage of c-tree replication.
You can enable transaction logging in the configuration by setting <transaction> in ctree.conf or iscobol.file.index.transaction.logging (boolean) among isCOBOL properties. This will affect new files.
Transaction logging can be applied to existing files using the -tron option of the ctutil utility.
Initial data synchronization
The Replication Agent replicates WRITE, REWRITE and DELETE operations as well as their equivalent SQL operations: INSERT, UPDATE and DELETE.
The creation of a new file is not replicated, instead.
For this reason it’s important to copy all the c-tree files that you wish to include in the replication from the Source c-tree server to the Target c-tree server. The c-tree file must exist in both servers for a successful replication.
Prepare the Source
To enable replication of all data files for this example, add the following configuration keyword to the ctsrvr.cfg configuration file of the Source c-tree server:
REPLICATE *.dat
Note - Certain FairCom files, such as REPLSTATEDT.FCS, must not be replicated. It is important to use a specific wild card that excludes the REPLSTATEDT.FCS file, such as REPLICATE *.dat. Using REPLICATE * may cause the replication of files that must not be replicated.
After this modification, start (or restart) the c-tree server.
Prepare the Target
Be sure this second c-tree server resides in its own directory and has a SERVER_NAME different than the name of the Source c-tree server.
If this second c-tree server is not running, start it.
Configure the Replication Agent
The Replication Agent is configured via a file named ctreplagent.cfg placed in the same directory of the ctreplagent executable (by default, the Replication subdirectory of the c-tree installation).
A default file is provided with the following content:
; Target server connection info
target_authfile target_auth.set
target_server FAIRCOMS@localhost
 
; Source server connection info
source_authfile source_auth.set
source_server FAIRCOMS@SourceIP
 
; Read 8 KB batches from source server
batch_size 8192
 
; Use a 5-second timeout when reading from source server
read_timeout_ms 5000
 
; Write change details to log file
;log_change_details changes.log
 
; The exception_mode option determines how the replication agent handles errors
; that occur when applying operations to the target server.
;
; exception_mode transaction
; When an operation fails, abort the transaction. This option preserves
; atomicity of transactions: either all or none of the operations for the
; transaction are applied to the target c-tree Server.
;
; exception_mode operation
; When an operation fails, continue the transaction, skipping only the
; operation that failed. This option does not preserve atomicity of
; transactions: only the operations that the replication agent successfully
; applies to the target c-tree Server are committed.
 
exception_mode transaction
 
; The source server will remember the replication agent's log position
 
; even when the replication agent disconnects.
;remember_log_pos yes
 
; End of File
Update the source_server and target_server entries by specifying the connection information for Source and Target c-tree servers.
The format can be one of the following syntaxes:
servername
servername@hostname
servername@IPaddress
#port@hostname
#port@IPaddress
If the host name or the IP address is omitted, host name defaults to localhost.
Start the Replication Agent by running the executable file:
ctreplagent
The output of this command is captured in a file named ctreplagent.log generated in the working directory of ctreplagent.
You will find something similar to the following output in ctreplagent.log when the utility connects and the transactions are processed:
Source server name : FAIRCOMS
 
Target server name : FAIRCOMT
 
Transactions per commit : 1
 
Starting log position : 0
 
Operating mode : Read and apply changes;
 
Wait when end of log data is reached.
 
Replication log reader connected to data source.
 
Connected to data target.
 
Starting scan with log 1, position 1
 
Processing log 1
 
Reached end of log data. Waiting for next log entry...
 
Reached end of log data. Waiting for next log entry...
 
Reached end of log data. Waiting for next log entry...
Also errors, if any, are registered in this file. The most common ones are discussed below, in the Troubleshooting chapter.
Testing the Repliaction Agent
When the Replication Agent and the two involved c-tree servers are up and running, you can start editing the c-tree files on the Source server. Every modification will be replicated to the corresponding files on the Target server.