For a more complex scenario, see the C Replicator (CREP) sample that is included with solidDB, see C Replicator sample.
The following set of scripts sets up a simple topology, a two-server system with one table in one partition. First, the replication is set up to be one-way only. After one row is successfully replicated, the system is configured to run two-way replication. Note that roles of servers are reversed when two-way replication is set up. Pay attention to server addresses.
Source database (tcp 1323): Create the table and define the partition that contains the table:
CREATE TABLE mytable (i INTEGER, j VARCHAR); COMMIT;
Source database (tcp 1323): Insert a row in the source database:
INSERT INTO mytable VALUES(1, 'row1'); COMMIT;
Target database (tcp 2323): Validate that the row is replicated to the target database:
SELECT i FROM mytable; COMMIT;
After these steps have been successfully executed, the system is now set up for one-way replication. To set up the replication in the opposite direction, the roles of the source and target databases are reversed. Pay attention to the addresses of the following nodes.
Original target becomes new source database (tcp 2323): Define the replication partition in the same way as you did for the original source database:
Original source becomes new target database (tcp 1323): Set up the replication connection and subscription and start replicating in the same way as you did for the original target database:
CREATE REPLICATION CONNECTION otherway_conn CONNECT TO 'tcp 2323' USING NAME dba PASSWORD dba; COMMIT;