通过同步

时间:2015-09-06 07:07:40

标签: mysql replication symmetricds

我第一次使用SymmetricDS并且我有两个表要同步。 1. Session_Tbl: - 此表从Store同步到公司。我无法生成session_tbl双向。 2. Products: - 此表在双向中同步。产品表与Session_tbl与PRODUCTS_SESSION FOREIGN KEY链接。

CREATE TABLE SESSION_TBL (
    SESSION_ID VARCHAR(45) NOT NULL,
    STATUS VARCHAR(15),
    CREATION_TIME DATETIME DEFAULT CURRENT_TIMESTAMP,
    MODIFICATION_TIME DATETIME ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (SESSION_ID)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    CREATE TABLE PRODUCTS (
    PRODUCT_ID VARCHAR(45) NOT NULL,
    REFERENCE VARCHAR(45) NOT NULL,
    CODE VARCHAR(100) NOT NULL,
    CODETYPE VARCHAR(10),
    NAME VARCHAR(100) NOT NULL, 
    SESSION_ID VARCHAR(45) NOT NULL,
    PRIMARY KEY (PRODUCT_ID),   
    CONSTRAINT PRODUCTS_SESSION FOREIGN KEY (SESSION_ID) REFERENCES SESSION_TBL(SESSION_ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

当我在商店中插入数据时,它同步到corp,因为sesison_tbl会将商店同步到corp,而产品表是双向的。 但是当我在产品表中插入任何产品时,我会在下面异常时因为会话ID在商店session_tbl中不存在: -

org.jumpmind.db.sql.SqlException: Cannot add or update a child row: a foreign key constraint fails

SymmetricDS中是否有任何配置可以获取发送产品数据的外键数据文件?

修改

添加了sym表数据: -

insert into SYM_NODE (node_id, node_group_id, external_id, sync_enabled, created_at_node_id)
  values ('000', 'backoffice', '000', 1, 'server');

  insert into SYM_NODE (node_id, node_group_id, external_id, sync_enabled, created_at_node_id)
  values ('001', 'pos', '001', 1, 'server');

insert into SYM_NODE_IDENTITY values ('000');

insert into sym_node_security (node_id,node_password,registration_enabled,registration_time,initial_load_enabled,initial_load_time,created_at_node_id)
 values ('000','5d1c92bbacbe2edb9e1ca5dbb0e661',0,current_timestamp,0,current_timestamp,'server');

 insert into sym_node_security (node_id,node_password,registration_enabled,registration_time,initial_load_enabled,initial_load_time,created_at_node_id)
 values ('001','5d1c92bbacbe2edb9e1ca5dbb0e661',0,current_timestamp,0,current_timestamp,'server');

 -- CREATE GROUP 

 insert into SYM_NODE_GROUP
        (node_group_id, description)
        values ('pos', 'A retail pos node');

insert into SYM_NODE_GROUP
        (node_group_id, description)
        values ('backoffice', 'A backoffice node');

    -- CREATE GROUP LINK

insert into SYM_NODE_GROUP_LINK
(source_node_group_id, target_node_group_id, data_event_action)
      values ('pos', 'backoffice', 'P');

insert into SYM_NODE_GROUP_LINK
(source_node_group_id, target_node_group_id, data_event_action)
      values ('backoffice', 'pos', 'W');

    insert into SYM_CHANNEL (channel_id, processing_order, max_batch_size, max_batch_to_send,
             extract_period_millis, batch_algorithm,data_loader_type, enabled, description)
         values ('pos_to_backoffice_default', 1, 1000, 10, 0, 'default','default', 1, 'pos_to_backoffice_default one directional');


insert into SYM_TRIGGER (trigger_id, source_table_name,
          channel_id,sync_on_incoming_batch, last_update_time, create_time)
                  values ('pos_to_backoffice_default', 'SESSION_TBL', 'pos_to_backoffice_default',1, current_timestamp, current_timestamp);


     insert into SYM_CHANNEL (channel_id, processing_order, max_batch_size, max_batch_to_send,
         extract_period_millis, batch_algorithm,data_loader_type, enabled, description)
     values ('twoway_default', 10, 1000, 10, 0, 'default','default', 1, 'twoway_default bidirectional');

 insert into SYM_TRIGGER (trigger_id, source_table_name,
          channel_id,sync_on_incoming_batch, last_update_time, create_time)
                  values ('twoway_default', 'PRODUCTS', 'twoway_default',1, current_timestamp, current_timestamp);

insert into SYM_TRIGGER_ROUTER
        (trigger_id, router_id, initial_load_order, create_time,
        last_update_time) values ('pos_to_backoffice_default', 'pos-2-backoffice', 1, current_timestamp,
        current_timestamp);

        insert into SYM_TRIGGER_ROUTER
        (trigger_id, router_id, initial_load_order, create_time,
        last_update_time) values ('twoway_default', 'backoffice-2-pos', 1, current_timestamp,
        current_timestamp);

        insert into SYM_TRIGGER_ROUTER
        (trigger_id, router_id, initial_load_order, create_time,
        last_update_time) values ('twoway_default', 'pos-2-backoffice', 1, 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 ('backoffice-2-pos','backoffice', 'pos','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 ('pos-2-backoffice','pos', 'backoffice','default',
        current_timestamp, current_timestamp);

由于 Anchit

0 个答案:

没有答案