如何在SymmetricDS中配置双向同步?

时间:2016-08-24 02:51:23

标签: symmetricds

有没有人使用SymmetricDS实现双向配置?

要配置很多东西,我得到了大部分内容:

server.properties:

#XXXXXXX nombre de la cabana
#SSSSSSS ip del servidor

engine.name=XXXXXXXXXXX

# The class name for the JDBC Driver
db.driver=com.mysql.jdbc.Driver
# The JDBC URL used to connect to the database
db.url=jdbc:mysql://localhost/HutteBullen_XXXXXXXXXXX?    tinyInt1isBit=false
# The user to login as who can create and update tables
db.user=aDDD
# The password for the user to login as
db.password=CC
registration.url=http://SSSSSSS:31415/sync/XXXXXXXXXXX
sync.url=http://SSSSSSS:31415/sync/XXXXXXXXXXX
# Do not change these for running the demo
group.id=server
external.id=000
initial.load.create.first=true
auto.registration = true
auto.reload = true
create.table.without.foreign.keys=true

客户端是嵌入式HSQL

client.properties(在代码中生成):

Properties props = new Properties();
            props.setProperty("engine.name", "cabana-" + args[0]);
            props.setProperty("db.driver", "org.hsqldb.jdbcDriver");
            props.setProperty("db.user", args[1]);
            props.setProperty("db.password", args[2]);
            props.setProperty("registration.url", "http://" + args[4] + ":31415/sync/" + args[5]);
            props.setProperty("group.id", "cabana");
            props.setProperty("external.id", args[0]);
            props.setProperty("job.routing.period.time.ms", "5000");
            props.setProperty("job.push.period.time.ms", "10000");
            props.setProperty("job.pull.period.time.ms", "10000");
            props.setProperty("job.heartbeat.period.time.ms", "15000");

            props.setProperty("intial.load.create.first", "true");
            props.setProperty("create.table.without.foreign.keys", "true");
            props.setProperty("create.table.without.defaults", "true");

触发器:

insert into sym_trigger (trigger_id,source_table_name, channel_id, last_update_time,create_time, sync_on_incoming_batch)
values('TriggerAll', '*', 'transaction', current_timestamp, current_timestamp,1);
insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time)
values('TriggerAll','server_2_cabana', 100, current_timestamp,current_timestamp);
insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time)
values('TriggerAll','cabana_2_server', 200, current_timestamp, current_timestamp); 

然后,问题是sym_conflict(在服务器中):

insert into sym_conflict (conflict_id, target_channel_id, source_node_group_id, target_node_group_id, detect_type, detect_expression, resolve_type,ping_back, resolve_changes_only, resolve_row_only, create_time, last_update_time)
values ('Conflict-Server-Cabana', 'transaction', 'server', 'cabana', 'USE_TIMESTAMP', 'LASTMODIFIEDUTCDATETIME', 'NEWER_WINS', 'REMAINING_ROWS', 0, 1, current_timestamp, current_timestamp);
insert into sym_conflict (conflict_id, target_channel_id, source_node_group_id, target_node_group_id, detect_type, detect_expression, resolve_type,ping_back, resolve_changes_only, resolve_row_only, create_time, last_update_time)
values ('Conflict-Cabana-Server', 'transaction', 'cabana', 'server', 'USE_TIMESTAMP', 'LASTMODIFIEDUTCDATETIME', 'NEWER_WINS', 'REMAINING_ROWS', 0, 1, current_timestamp, current_timestamp);

最大的问题是下一个问题: 我有很多节点在星形拓扑中同步。所有这些都以双向方式同步。它们都具有相同的模式,并且应该具有完全相同的数据。

插入和更新可以使用上面的配置正常工作。问题是删除。我是节点一,我创建一行,然后它同步到中央服务器,然后到节点二。然后节点2决定删除这一行,它会在节点2上删除,然后在服务器上删除,但不会在创建该行的节点上删除,我不知道为什么!它并不保持一致。

是否有人使用SymmetricDS实现完全双向复制?

1 个答案:

答案 0 :(得分:0)

按照文档http://www.symmetricds.org/doc/3.8/html/user-guide.html#_bi_directional_synchronization

中的说明将列sync_on_incoming_batch的值设置为1