gpt4 book ai didi

postgresql - 使用 SymmetricDS 的主动-主动 PostgreSQL 配置

转载 作者:行者123 更新时间:2023-12-05 09:32:18 28 4
gpt4 key购买 nike

我在使用 SymmetricDS(开源版本)在 2 个 Postgres 服务器之间复制数据时遇到问题。以下是了解我的问题的相关信息:

我已经用 Vagrant 部署了 3 个服务器:

  • symmetricds.local [192.168.44.9]
  • postgres01.local [192.168.44.10]
  • postgres02.local [192.168.44.11]

symmetricds.local 服务器中,我将 SymmetricDS 安装为一项服务。在 postgres##.local 服务器上安装 postgres 11 并加载 Sakila data (示例数据)。

然后我在 symmetricds.local 服务器中创建以下配置文件:

cat <<EOF >>/opt/symmetric-server-3.12.10/engines/postgres01.properties
engine.name=postgres01
db.driver=org.postgresql.Driver
db.url=jdbc:postgresql://192.168.44.10:5432/postgres?stringtype=unspecified
db.user=postgres
db.password=postgres
registration.url=
sync.url=http://192.168.44.9:31415/sync/postgres01
group.id=primary
external.id=postgres01
auto.registration=true
initial.load.create.first=true
EOF

cat <<EOF >>/opt/symmetric-server-3.12.10/engines/postgres02.properties
engine.name=postgres02
db.driver=org.postgresql.Driver
db.url=jdbc:postgresql://192.168.44.11:5432/postgres?stringtype=unspecified
db.user=postgres
db.password=postgres
registration.url=http://192.168.44.9:31415/sync/postgres01
sync.url=http://192.168.44.9:31415/sync/postgres02
group.id=primary
external.id=postgres02
EOF

之后我启动 SymmetricDS 服务:

sudo /opt/symmetric-server-3.12.10/bin/sym_service start

此时所有 sym_ 表都在两个 Postgres 服务器中创建。

我在 postgres01.local 服务器中添加了一些数据,以便在两个 Postgres 服务器之间进行复制:

INSERT INTO sym_node_group_link (source_node_group_id,target_node_group_id,data_event_action)
VALUES ('primary','primary','P');

INSERT INTO sym_trigger (trigger_id, source_schema_name, source_table_name, channel_id, sync_on_update, sync_on_insert, sync_on_delete, sync_on_update_condition, sync_on_insert_condition, sync_on_delete_condition, last_update_time, create_time)
VALUES ('public.all', 'public', '*', 'default', 1, 1, 1, '1=1', '1=1', '1=1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

INSERT INTO sym_router (router_id,source_node_group_id,target_node_group_id,router_type,router_expression,sync_on_update,sync_on_insert,sync_on_delete,use_source_catalog_schema,create_time,last_update_by,last_update_time)
VALUES ('primary_2_primary', 'primary', 'primary', 'default', NULL, 1, 1, 1, 0, CURRENT_TIMESTAMP, 'console', CURRENT_TIMESTAMP);

INSERT INTO sym_trigger_router (trigger_id, router_id, enabled, initial_load_order, create_time, last_update_time)
VALUES ('public.all', 'primary_2_primary', 1, 10, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

最后,我在 symmetricds.local 服务器中运行它以允许注册:

sudo /opt/symmetric-server-3.12.10/bin/symadmin -e postgres01 open-registration primary postgres02

几分钟后,创建触发器并在 sym_ 表之间共享数据。但不会复制用户数据(Sakila 表)。

我尝试强制重新加载表:

INSERT INTO sym_table_reload_request (source_node_id, target_node_id, trigger_id, router_id, create_time, last_update_time) VALUES ('postgres01', 'postgres02', 'ALL', 'ALL', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

但随后我在 SymmetricDS 日志中收到此错误:

2021-07-01 15:03:19,097 ERROR [postgres01] [InitialLoadService] [postgres01-job-11] Error while queuing initial loads StackTraceKey.init [SymmetricException:46596748] org.jumpmind.symmetric.SymmetricException: Unable to issue an update for sym_node_security.  Check the sym_trigger_hist for sym_node_security.
at org.jumpmind.symmetric.service.impl.DataService.insertNodeSecurityUpdate(DataService.java:2230)
at org.jumpmind.symmetric.service.impl.DataService.insertSqlEventsPriorToReload(DataService.java:1227)
at org.jumpmind.symmetric.service.impl.DataService.insertReloadEvents(DataService.java:1006)
at org.jumpmind.symmetric.service.impl.InitialLoadService.processTableRequestLoads(InitialLoadService.java:282)
at org.jumpmind.symmetric.service.impl.InitialLoadService.queueLoads(InitialLoadService.java:98)
at org.jumpmind.symmetric.job.InitialLoadJob.doJob(InitialLoadJob.java:43)
at org.jumpmind.symmetric.job.AbstractJob.invoke(AbstractJob.java:227)
at org.jumpmind.symmetric.job.AbstractJob.run(AbstractJob.java:298)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)

2021-07-01 15:03:29,118 INFO [postgres01] [InitialLoadService] [postgres01-job-14] Found 1 table reload requests to process.
2021-07-01 15:03:29,131 INFO [postgres01] [InitialLoadService] [postgres01-job-14] Cancelling load 2 for node postgres02
2021-07-01 15:03:29,134 INFO [postgres01] [InitialLoadService] [postgres01-job-14] Marked 1 load requests as OK for node postgres02
2021-07-01 15:03:29,136 INFO [postgres01] [InitialLoadService] [postgres01-job-14] Marked 0 extract requests as OK for node postgres02
2021-07-01 15:03:29,137 INFO [postgres01] [InitialLoadService] [postgres01-job-14] Marked 0 batches as OK for node postgres02
2021-07-01 15:03:29,147 INFO [postgres01] [DataService] [postgres01-job-14] Queueing up an initial load to node postgres02
2021-07-01 15:03:29,175 ERROR [postgres01] [InitialLoadService] [postgres01-job-14] Error while queuing initial loads StackTraceKey [SymmetricException:46596748]

仍然没有任何内容被复制,sym_trigger_hist 表在 postgres01 上是空的,但在 postgres02 上充满了所有表。

Cloud 你能帮助我了解我的配置问题吗?

最佳答案

您应该在 postgres01 上运行 symadmin sync-triggers 命令来构建触发器。检查日志以查看是否有任何错误。如果触发器创建成功,sym_trigger_hist 表应该填充到 postgres01 中。

构建触发器要执行的命令是:

symadmin sync-triggers -e postgres01

关于postgresql - 使用 SymmetricDS 的主动-主动 PostgreSQL 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68213144/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com