CSQL Replication offers complete data protection through automated, real-time, zero-latency fail over and recovery with high availability and load balancing cluster for CSQL MMDB. It provides both synchronous and asynchronous transaction propagation to peer instances. It enables scaling application throughput by sharing the read load across replicated CSQL instances.
Operational Restrictions
Replication imposes the following operational Restrictions:
- Replication is supported between CSQL instances
- A CSQL server instance can participate in only one quorum.
Once a table is replicated DDL statements cannot be executed on that table.
The following additional restrictions also apply to tables defined for replication:
- The Primary key constraint not to be removed.
- Column not to be dropped or added.
- The Primary key column not to be modified.
The following SQL statements are permitted:
Configuration Parameter
The database server configuration file (csql.conf) under CSQL root directory includes eleven configuration parameters that affect the behavior of Replication.
Replication Configuration parameters:
SITE_ID
REPLICATION
REPLICATION_SITES
NETWORK_CONFIG_FILE
CONFL_RESOL_FILE
MSG_KEY
ASYNC_MSGMAX
MAX_QUEUE_LOGSNetwork Configuration Parameters:
CSQL_SQL_SERVER
PORT
Setting up parameters in csql.conf file
The configuration file, csql.conf has eleven parameters that need to be set up for
replication. Some of the parameters are present in Cache Section and most are present in
SQL Network Server Section in csql.conf file.
This is a Boolean parameter and should be set to true to enable replication across site.
This is an integer parameter and it identifies a CSQL instance in a quorum.Set this to a unique value for all the nodes in the quorum. For example, this parameter will be set to 1 for CSQL Instance-1 and will be set to 2 for CSQL Instance-2 and so on.
This is a Boolean parameter and should be set to true when replication is turned on.
This is an integer parameter to set the port for network access, by default it is set to the number 5678.
This is a string parameter, which contains the complete path to the file, which holds the complete information about the peer site information in the quorum.
This is an integer parameter is used for creating message queue for MsgQueue server. It is used when replication mode is Asynchronous only. This is an internal parameter and user need not modify this value.
The two instances of CSQL should work in two different machines, for that we have to configure the replication and set up the network file which contains the information about the peer site.
Based on this deployment, CSQL Instance-1 is considered as Source site or Active Site, CSQL Instance –2 is considered as Destination Site or Standby Site. The Replication
configuration is made accordingly both in csql.conf file and csqlnw.conf file.
Configure csql.conf file for CSQL Instance – 1.
The replication configuration parameters are as follows.
SYS_DB_KEY=3001
USER_DB_KEY=4001
LOG_FILE=/tmp/SITE1/log/csql/log.out
DATABASE_FILE=/tmp/SITE1/csql/db
SITE_ID=1
TABLE_CONFIG_FILE=/tmp/SITE1/csqltable.conf
DS_CONFIG_FILE=/tmp/SITE1/csql/csqlds.conf
CONFL_RESOL_FILE=/tmp/SITE1/csql/conflResoFile.txt
CACHE_MODE=SYNC
CSQL_SQL_SERVER=true
PORT=5001
REPLICATION=true
MSG_KEY=2531
ID_SHM_KEY=1951
NETWORK_CONFIG_FILE=/tmp/SITE1/csqlnw.conf
Configure csql.conf file for CSQL Instance – 2
The replication configuration parameters are as follows.
SYS_DB_KEY=3002
USER_DB_KEY=4002
LOG_FILE=/tmp/SITE2/log/csql/log.out
DATABASE_FILE=/tmp/SITE2/csql/db
SITE_ID=2
TABLE_CONFIG_FILE=/tmp/SITE2/csqltable.conf
DS_CONFIG_FILE=/tmp/SITE2/csql/csqlds.conf
CONFL_RESOL_FILE=/tmp/SITE2/csql/conflResoFile.txt
CACHE_MODE=SYNC
CSQL_SQL_SERVER=true
PORT=5002
REPLICATION=true
MSG_KEY=2532
ID_SHM_KEY=1952
NETWORK_CONFIG_FILE=/tmp/SITE2/csqlnw.conf
Configure csqlnw.conf file for each instance:
The network configuration file should contain the information about both the CSQL Instances and it should contain the below specified information. The file path has to be mentioned in the NETWORK_CONFIG_FILE parameter in csql.conf file.
File Format:
ID : IP_address : Port : Repl_Mode
Synchronous Replication
In case of synchronous mode, source site transaction commits return only after the transaction is committed at source instance and other destination instances in the quorum.
Information in csqlnw.conf file at Instance-1
1:localhost:5001:SYNC
2:localhost:5002:SYNC
Information in csqlnw.conf file at Instance-2
1:localhost:5001:SYNC
2:localhost:5002:SYNC
Steps to replicate table :
Follow the below steps to replicate data from Instance-1 to Instance-2. Before beginning with operations, Start the CSQL Server in two hosts with all necessary
configuration parameters in csql.conf file.
Start the CSQL Server at both the Instances.
The below contents shows that all the required servers are running and it should match at
both the Sites except Server’s PID value.
$csqlserver
Sys_DB [Size=0001MB]
User_DB [Size=0010MB]
Network Server Started [PID=21640]
Replication Server Started [PID=21641]
Database Server Started…
Replicate the table at Instance-1 using “repltable” tool
Assume that the “emp” table is present at the Instance-1 with some records. Use repltable tool to replicate the table.
$csql
CSQL> create table emp(f1 int, f2 int);
$ repltable –t emp
After executing this command entry will be made into the csqltable.conf file.
Replicate the table at Instance-2
By executing the below command the table is replicated at Instance-2 and the entry is made in csqltable.conf file.
$ repltable –t emp
Now the table ‘t1’ is present in Source Site as well as in Destination Site. Insert some records using csql tool with -r option at Instance-1 and it will be replicated to
Instance-2.