0

我正在尝试设置从 postgres DB 源(pg 11.7,pglogical 2.2.1)到目标(pg 13.5,pglogical 2.3.3)的复制

跨数据库的连接和访问被配置和测试。

我已经手动将角色从源复制到目标pg_dump -g globals,然后psql -f globals.sql在目标上使用源。

我已经手动将模式从源复制到目标pg_dump -Fc -s -f ~/schema.dmp mydatabase,然后pg_restore -d mydatabase schema.dmp在目标上使用源。

我已经修改了每个 DBs postgres.conf :

wal_level='logical'
max_worker_processes=10
max_replcation_slots=10
max_wal_senders=10
shared_preload_libraries='pglogical'

在我alter system set shared_preload_libraries = 'pglogical';和重新启动的两个数据库上

在两个数据库上我CREATE EXTENSION pglogical;

在源我创建节点SELECT pglogical.create_node(node_name := 'provider', dsn := 'host=<source_IP> port=5432 dbname=mydatabase user=pglogical password=<password>');

在源上,我将所有表添加到复制集中SELECT pglogical.replication_set_add_all_tables('default', '{public}'::text[]);

在源上,我将所有序列添加到复制集中SELECT pglogical.replication_set_add_all_sequences(set_name := 'default', schema_names := '{public}'::text[], synchronize_data := true );

在目标上我创建节点SELECT pglogical.create_node(node_name := 'subscriber', dsn := 'host=<target_IP> port=5432 dbname=mydatabase user=pglogical password=<password>');

最后我尝试使用 `SELECT pglogical.create_subscription(subscription_name := 'subscription', provider_dsn := 'host=<target_IP> port=5432 dbname=mydatabase user=pglogical password=', replication_sets := '{默认}'::text[]);

这导致源上出现以下错误:

ERROR:  could not fetch remote node info: ERROR:  function pglogical.pglogical_node_info() does not exist
LINE 1: ..., node_name, sysid, dbname, replication_sets FROM pglogical....
                                                             ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

并在目标日志中发现此错误:

LOG:  connection authorized: user=pglogical database=mydatabase SSL enabled (protocol=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384, bits=256, compression=off)
ERROR:  function pglogical.pglogical_node_info() does not exist at character 65
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
STATEMENT:  SELECT node_id, node_name, sysid, dbname, replication_sets FROM pglogical.pglogical_node_info()

我已经尝试了包含所有类型转换的 pglogical.create_subscription 函数,它没有改变任何东西。

在我看到的目标上:

postgres=# select * from pglogical.pglogical_node_info()
;
  node_id   | node_name  |        sysid        |  dbname  |               replication_sets
------------+------------+---------------------+----------+----------------------------------------------
 2941155235 | subscriber | 7067748448099432568 | postgres | "걵wN`PXU","\x04\x0B鐣wNPXU","\x0FNl7wNxPXU"
(1 row)

在我看到的来源:

postgres=# select * from pglogical.pglogical_node_info()
;
  node_id   |       node_name       |        sysid        |  dbname  |             replication_sets
------------+-----------------------+---------------------+----------+-------------------------------------------
 2678724765 | provider | 6825764350976429997 | postgres | "\x08P\x180U"," \x03;%\x180U","BBԝ\x180U"
(1 row)

为什么我不能创建此订阅?pglogical 是否支持从 PG11.7 到 PG13.5 的流式传输?

4

1 回答 1

0

I think your create_subscription statement is incorrect.

pglogical.create_subscription(subscription_name := 'subscription', provider_dsn := 'host=<target_IP> port=5432 dbname=mydatabase user=pglogical password=', replication_sets := '{default}'::text[]);

You are including <target_IP> instead of <source_IP>

Another possible issue - I'm not sure about your syntax for replication sets. You may want to remove that. You don't need to list them again here as you've already set it up at the node level.

Further resources:

  1. pglogical docs. Search for references to create_subscription
  2. Helpful AWS blog post walkthrough for using pglogical. I am using now myself to upgrade PG.
于 2022-03-04T16:08:30.577 回答