簡體   English   中英

postgres 邏輯復制不起作用。 錯誤提示“無法連接到發布者”

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM