我正在尝试在两个数据库实例之间设置逻辑复制。
我在主数据库上创建了一个发布,并在副本上创建了一个订阅。具体来说:
在主数据库上:
create publication chris for all tables;
在副本数据库上:
CREATE SUBSCRIPTION chris
CONNECTION 'host=localhost port=5540 dbname=finder connect_timeout=10'
PUBLICATION chris;
但是由于某种原因,副本似乎没有识别出版物(本质上ERROR: could not receive data from WAL stream: ERROR: publication "chris" does not exist
)(来自副本的日志):
Oct 20 18:18:31 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start[289]: 2020-10-20 18:18:31.013 GMT [289] LOG: background worker "logical replication worker" (PID 3035) exited with exit code 1
Oct 20 18:18:36 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start[289]: 2020-10-20 18:18:36.020 GMT [3036] LOG: logical replication apply worker for subscription "chris" has started
Oct 20 18:18:36 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start[289]: 2020-10-20 18:18:36.022 GMT [3036] ERROR: could not receive data from WAL stream: ERROR: publication "chris" does not exist
Oct 20 18:18:36 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start[289]: CONTEXT: slot "chris", output plugin "pgoutput", in the change callback, associated LSN 0/6BA6EC8
Oct 20 18:18:36 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start[289]: 2020-10-20 18:18:36.023 GMT [289] LOG: background worker "logical replication worker" (PID 3036) exited with exit code 1
Oct 20 18:18:41 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start[289]: 2020-10-20 18:18:41.030 GMT [3039] LOG: logical replication apply worker for subscription "chris" has started
Oct 20 18:18:41 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start[289]: 2020-10-20 18:18:41.033 GMT [3039] ERROR: could not receive data from WAL stream: ERROR: publication "chris" does not exist
Oct 20 18:18:41 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start[289]: CONTEXT: slot "chris", output plugin "pgoutput", in the change callback, associated LSN 0/6BA6EC8
Oct 20 18:18:41 test2 8y7qb8wz8ps875yrvpmg9c1zsffls4hy-unit-script-postgresql-start[289]: 2020-10-20 18:18:41.034 GMT [289] LOG: background worker "logical replication worker" (PID 3039) exited with exit code 1
奇怪的是,主数据库的日志似乎也显示了相同的错误(ERROR: publication "chris" does not exist
):
Oct 20 18:22:56 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start[260]: 2020-10-20 18:22:56.545 GMT [514] CONTEXT: slot "chris", output plugin "pgoutput", in the change callback, associated LSN >
Oct 20 18:23:01 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start[260]: 2020-10-20 18:23:01.555 GMT [515] LOG: starting logical decoding for slot "chris"
Oct 20 18:23:01 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start[260]: 2020-10-20 18:23:01.555 GMT [515] DETAIL: Streaming transactions committing after 0/6BA6E60, reading WAL from 0/6BA6E28.
Oct 20 18:23:01 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start[260]: 2020-10-20 18:23:01.555 GMT [515] LOG: logical decoding found consistent point at 0/6BA6E28
Oct 20 18:23:01 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start[260]: 2020-10-20 18:23:01.555 GMT [515] DETAIL: There are no running transactions.
Oct 20 18:23:01 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start[260]: 2020-10-20 18:23:01.556 GMT [515] ERROR: publication "chris" does not exist
Oct 20 18:23:01 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start[260]: 2020-10-20 18:23:01.556 GMT [515] CONTEXT: slot "chris", output plugin "pgoutput", in the change callback, associated LSN >
Oct 20 18:23:06 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start[260]: 2020-10-20 18:23:06.566 GMT [518] LOG: starting logical decoding for slot "chris"
Oct 20 18:23:06 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start[260]: 2020-10-20 18:23:06.566 GMT [518] DETAIL: Streaming transactions committing after 0/6BA6E60, reading WAL from 0/6BA6E28.
Oct 20 18:23:06 pgtestpublic 22rj0nr8pn1k0r3q8q6pxixp6hn2zi4i-unit-script-postgresql-start[260]: 2020-10-20 18:23:06.566 GMT [518] LOG: logical decoding found consistent point at 0/6BA6E28
但是我确实看到了正确的预期输出:
select * from pg_catalog.pg_publication;
select * from pg_catalog.pg_publication;
在主数据库上。
我可以进一步调查什么?什么可能是错误的原因?
我完全忘记指定用户名和密码。也许它默认使用了一些默认的用户/密码组合。否则,可能会出现误导性错误消息。