Search code examples
databasesymmetricds

SymmetricDS:Creating 2 server nodes referencing same DB


So i have a scenario here. I have a Central Database, say DB0. I also have two smaller databases, say DB1 and DB2 which are accessed by my applications, say App1 and App2 respectively. I want to replicate contents of DB0 to DB1 and DB2. For this I'm using Symmetricds.

Now this is where i'm having a doubt. I understand that I can create a CentralNode-00 pointing to DB0 and 2 ClientNodes, ClientNodes-01 and ClientNodes-02 pointing to DB1 and DB2 respectively and easily do the replication.

But I'm trying to use SymmetricDS in embedded mode with my Java. So this is how I'd like to do this:

From App1, I'd like to start a Symmetric-Server Central-00 pointing to DB0 and a Symmetric-Client Client-01 pointing to DB1. Similarly from App2, I'd like to start another instance of Symmetric-Server Central-00 pointing to DB0 and a Symmetric-Client Client-02 pointing to DB2. Obviously, App1 and App2 will be started in its own JVM.

So my question is this, Can I start two instances of the same Symmetric-Server Central-00 on two different VMs. Simply put, can i start two symmetricds server nodes that are accessing the same DB(also the same SYM tables generated within this DB.)?

This is the cofiguration that I inserted in the Central DB.

insert into sym_channel 
(channel_id, processing_order, max_batch_size, enabled, description)
values('item', 1, 100000, 1, 'Item and pricing data');

insert into sym_node_group (node_group_id) values ('corp');
insert into sym_node_group (node_group_id) values ('store');
insert into sym_node_group (node_group_id) values ('store02');

insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('corp', 'store', 'W');
insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('corp', 'store02', 'W');
insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('store', 'corp', 'P');
insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('store02', 'corp', 'P');

insert into sym_trigger 
(trigger_id,source_table_name,channel_id,last_update_time,create_time)
values('item','item','item',current_timestamp,current_timestamp);

insert into sym_router 
(router_id,source_node_group_id,target_node_group_id,router_type,create_time,last_update_time)
values('corp_2_store', 'corp', 'store', 'default',current_timestamp, current_timestamp);

insert into sym_router 
(router_id,source_node_group_id,target_node_group_id,router_type,create_time,last_update_time)
values('corp_2_store02', 'corp', 'store02', 'default',current_timestamp, current_timestamp);

insert into sym_trigger_router 
(trigger_id,router_id,initial_load_order,last_update_time,create_time)
values('item','corp_2_store', 100, current_timestamp, current_timestamp);

insert into sym_trigger_router 
(trigger_id,router_id,initial_load_order,last_update_time,create_time)
values('item','corp_2_store02', 100, current_timestamp, current_timestamp);

But when i start the instances it throws a Primary Key Violation Exception.

So could someone tell me whether this is possible or not? if so could you point out my mistakes?


Solution

  • No! Only one instance, only one symmetricds engine should be pointing to one db. Why don't you use multiengine mode and start all three engineers from one JVM client?