为两个Azure SQL数据库(即Staging_Prod和DBSYNC_STAGING_PROD)运行SymmetricDS进行Azure SQL数据库的数据库同步时,我遇到以下错误。
2018-10-22 06:50:46,706 WARN [secondary-staging_prod-us-001] [JdbcSqlTemplate] [secondary-staging_prod-us-001-dataloader-6] Foreign key 'FK_AccessMaster_ToFunctions' references invalid table 'STAGING_PROD.Functions'.. Failed to execute: ALTER TABLE "dbo"."AccessMaster"
ADD CONSTRAINT "FK_AccessMaster_ToFunctions" FOREIGN KEY ("FunctionID") REFERENCES "STAGING_PROD"."Functions" ("id")
2018-10-22 06:50:46,706 ERROR [secondary-staging_prod-us-001] [DefaultDatabaseWriter] [secondary-staging_prod-us-001-dataloader-6] Failed to alter table using the following xml: <?xml version="1.0"?>
<!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database">
<database name="dataextractor" schema="dbo">
<table name="AccessMaster">
<column name="Id" primaryKey="true" required="true" type="INTEGER" size="10" autoIncrement="true">
<platform-column name="mssql2008" type="int identity" size="10"/>
</column>
<column name="HTML_UI_ID" required="true" type="VARCHAR" size="50">
<platform-column name="mssql2008" type="varchar" size="50"/>
</column>
<column name="Name" required="true" type="VARCHAR" size="50">
<platform-column name="mssql2008" type="varchar" size="50"/>
</column>
<column name="Value" required="true" type="BIGINT" size="19">
<platform-column name="mssql2008" type="bigint" size="19"/>
</column>
<column name="FunctionID" required="true" type="INTEGER" size="10">
<platform-column name="mssql2008" type="int" size="10"/>
</column>
<foreign-key name="FK_AccessMaster_ToFunctions" foreignTable="Functions" foreignTableCatalog="STAGING_PROD" foreignTableSchema="">
<reference local="FunctionID" foreign="ID"/>
</foreign-key>
<unique name="AK_AccessMaster_HTML_UI_ID_FunctionID">
<unique-column name="HTML_UI_ID"/>
<unique-column name="FunctionID"/>
</unique>
</table>
</database> StackTraceKey [SqlException:1229404539]
2018-10-22 06:50:46,752 ERROR [secondary-staging_prod-us-001] [ManageIncomingBatchListener] [secondary-staging_prod-us-001-dataloader-6] Failed to load batch 000-11 StackTraceKey [SqlException:1229404539]
SymmetricDS配置表如下。
insert into sym_node_group (node_group_id) values ('primary-staging_prod-us');
insert into sym_node_group (node_group_id) values ('secondary-staging_prod-us');
insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('primary-staging_prod-us', 'secondary-staging_prod-us', 'W');
insert into sym_node_group_link (source_node_group_id, target_node_group_id, data_event_action) values ('secondary-staging_prod-us', 'primary-staging_prod-us', 'P');
insert into sym_trigger
(trigger_id,source_catalog_name,source_schema_name, source_table_name, channel_id, sync_on_insert, sync_on_update, sync_on_delete, last_update_time,create_time, sync_on_incoming_batch)
values('TriggerAll', null, 'dbo', '*', 'matter', 1 , 1, 1, GetDate(), GetDate(), 1);
insert into sym_router
(router_id,source_node_group_id,target_node_group_id,target_catalog_name,target_schema_name,target_table_name,router_type,create_time,last_update_time)
values('primary_2_secondary-staging_prod-us', 'primary-staging_prod-us', 'secondary-staging_prod-us', null, 'dbo', '*', 'default',GetDate(), GetDate());
insert into sym_router
(router_id,source_node_group_id,target_node_group_id,target_catalog_name,target_schema_name,target_table_name,router_type,create_time,last_update_time)
values('secondary_2_primary-staging_prod-us', 'secondary-staging_prod-us', 'primary-staging_prod-us', null, 'dbo', '*', 'default', GetDate(), GetDate());
insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time)
values('TriggerAll','primary_2_secondary-staging_prod-us', 100, current_timestamp,current_timestamp);
insert into sym_trigger_router (trigger_id,router_id,initial_load_order,last_update_time,create_time)
values('TriggerAll','secondary_2_primary-staging_prod-us', 200, current_timestamp, current_timestamp);
但是,如果我使用正确的目标架构在下面的SQL Server Management Studio中执行alter命令,它将运行正常。
ALTER TABLE "dbo"."AccessMaster"
ADD CONSTRAINT "FK_AccessMaster_ToFunctions" FOREIGN KEY ("FunctionID") REFERENCES "DBSYNC_STAGING_PROD"."dbo"."Functions" ("id")
SymmetricDS版本==>对称服务器-3.9.14
我认为这个问题即将到来,因为我无法指定目标架构/目录名称。您能否指导我完成新symmetricDS版本中的配置步骤。
问候 拉贾特·阿格劳瓦尔(Rajat Agrawal)
答案 0 :(得分:0)
问题已解决。看起来好像在2018年10月3日发布的SymmetricDS版本3.9.14中存在一个错误。我刚刚下载了在2018年8月9日发布的稳定版本3.8.40,该错误消失了,我能够在没有任何外键的情况下同步模式更改引用错误。
致谢
Rajat Agrawal