我正在嘗試使用兩個本地 postgresql 服務器(node1:埠 5434,node2:埠 5435)創建邏輯復制。
我可以成功地在 node1 和 node2 上為公共模式中的表創建發布和訂閱。
節點1:
CREATE PUBLICATION my_pub FOR TABLE t1;
GRANT SELECT ON t1 TO repuser;
節點2:
CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5434 dbname=pub user=repuser password=password' PUBLICATION my_pub;
Node2 public.t1 復制 node1 public.t1 中的所有資料。
但是,我的問題是當我使用相同的代碼但在不同的模式中創建發布和訂閱時,node2 無法復制。
下面是一些 pg_catalog 查詢的輸出:
節點1:
pub=# select * from pg_catalog.pg_publication_tables;
pubname | schemaname | tablename
---------- ------------ -----------
my_pub | public | t1
cdl_test | cdl | t1
pub_test | test | t1
節點2:
sub=# \dRs
List of subscriptions
Name | Owner | Enabled | Publication
-------------- ---------- --------- -------------
cdl_sub_test | postgres | t | {cdl_test}
my_sub | postgres | t | {my_pub}
sub_test | postgres | t | {pub_test}
sub=# select * from pg_catalog.pg_replication_origin;
roident | roname
--------- ----------
2 | pg_18460
1 | pg_18461
3 | pg_18466
sub=# select * from pg_catalog.pg_subscription_rel ;
srsubid | srrelid | srsubstate | srsublsn
--------- --------- ------------ ------------
18461 | 16386 | r | 0/3811C810
18466 | 18463 | d |
18460 | 18456 | d |
如圖所示select * from pg_catalog.pg_subscription_rel,兩個訂閱 test 和 cdl schema 處于d(data is being copied)狀態。
關于如何解決此問題或診斷問題發生原因的任何建議?
正如 jjanes 所建議的,日志檔案的片段如下所示:
2022-01-17 16:05:25.165 PST [622] WARNING: out of logical replication worker slots
2022-01-17 16:05:25.165 PST [622] HINT: You might need to increase max_logical_replication_workers.
2022-01-17 16:05:25.168 PST [970] LOG: logical replication table synchronization worker for subscription "cdl_sub_test", table "t1" has started
2022-01-17 16:05:25.245 PST [970] ERROR: could not start initial contents copy for table "cdl.t1": ERROR: permission denied for schema cdl
2022-01-17 16:05:25.247 PST [471] LOG: background worker "logical replication worker" (PID 970) exited with exit code 12022-01-17 16:05:25.797 PST [488] postgres@sub LOG: statement: /*pga4dash*/
即使在我授予SELECT ON cdl.t1 TO repuser;.
uj5u.com熱心網友回復:
您必須授予用戶repuser讀取應復制的表的權限。這也需要USAGE對包含該表的架構的權限。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/415509.html
標籤:
