![](/img/trans.png)
[英]Postgres Logical Replication: Replication slot, Subscriber and Publisher Creation Order Matters?
[英]postgres logical replication not working. Error says "could not connect to the publisher"
我的 windows 电脑上有一个名为salephone_test
的 postgres 数据库,其中包含 3 个表( smartphones, listings, phone_listings
),我想将其复制到 digitalocean 上的至少一个 ubuntu 液滴。 我尝试了以下设置来复制智能手机表:
在postgresql.conf
中的本地计算机(pc)上,我在pg_hba.conf
中设置了listen_addresses = '*'
和wal_level = logical
,我添加了以下几行
host salephone_test rep 0.0.0.0/0 md5
host salephone_test all 104.248.54.230/0 md5
host all all 0.0.0.0/0 md5
host all all 0.0.0.0/0 md5
其中104.248.54.230
是我的 digitalocean 液滴的 IP 我还通过以下命令设置了复制用户和发布
CREATE ROLE rep REPLICATION LOGIN PASSWORD 'fakepass';
GRANT SELECT on smartphones to rep;
CREATE PUBLICATION test_phones FOR TABLE smartphones;
在我的远程 droplet 上,在 ubuntu 上安装 postgres 后,我创建了一个名为salephone
的数据库,在 psql 中创建了一个名为smartphones
的表,然后我使用以下命令订阅逻辑复制
// 50.71.125.50 is my pc ip according to google
CREATE SUBSCRIPTION phone_sub CONNECTION 'dbname = salephone_test host = 50.71.125.50 user = rep password = fakepass port = 5432' PUBLICATION test_phones;
经过一分钟的等待,我收到了以下信息
ERROR: could not connect to the publisher: connection to server at "50.71.125.50", port 5432 failed: Connection timed out
Is the server running on that host and accepting TCP/IP connections?
注意:我已经通过 services.msc 多次尝试在我的电脑上重新启动 postgres
您的家庭调制解调器/路由器肯定会阻止连接。 您需要将其配置为接受连接并对您的电脑进行“端口转发”。 您如何做到这一点(或者甚至可能)将取决于路由器的品牌和 model。
此外,您的 pg_hba 没有多大意义。 在更一般的条目之上有更具体的条目的原因是为其提供不同的身份验证方法(或配置)。 由于您的所有条目都具有相同的方法,因此您最好只使用最后一行而不使用前面的 3。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.