注意:node
一、9.5以上版本才支持數據庫
二、編譯安裝參考https://www.2ndquadrant.com/en/resources/pglogical/pglogical-installation-instructions/bash
三、如何使用參考https://www.2ndquadrant.com/en/resources/pglogical/pglogical-docs/,服務器
中文參考https://my.oschina.net/innovation/blog/748227ide
四、本教程支持pg自身的流複製主備模式,pglogical是hotstanby的流複製高級模式post
五、訂閱服務器版本要和提供者版本同樣,且都要安裝pglogicalspa
1、安裝pglogical.net
因爲咱們pg都是源碼安裝,那麼pglogical也是源碼安裝orm
去官網https://www.2ndquadrant.com下載源碼包,比較難找,慢慢找blog
安裝須要pg_config,因爲咱們pg安裝完環境變量是配置在postgres用戶根目錄下的.bash_profile裏面,在root用戶下須要source /home/postgres/.bash_profile加載下環境變量
解壓後執行
make USE_PGXS=1
make USE_PGXS=1 install
2、配置pglogical
一、PG配置
若是是主備模式,兩個都得修改,記得重啓服務
wal_level = 'logical' max_worker_processes = 10 # one per database needed on provider node # one per node needed on subscriber node max_replication_slots = 10 # one per node needed on provider node max_wal_senders = 10 # one per node needed on provider node shared_preload_libraries = 'pglogical'
track_commit_timestamp = on # needed for last/first update wins conflict resolution # property available in PostgreSQL 9.5+
二、配置邏輯複製
提供者執行如下命令,固然首先要確認數據庫和用戶,命令\c dbname user
CREATE EXTENSION pglogical; SELECT pglogical.create_node('provider1','host=192.168.180.222 port=5433 dbname=elink'); SELECT pglogical.replication_set_add_table('default','company','true',NULL,NULL); #default是複製表的全部操做,company是表名
訂閱者執行如下命令
select pglogical.create_node('sub_node_1','host=192.168.180.222 port=5433 dbname=elink'); select pglogical.create_subscription('sub1','host=192.168.180.222 port=5433 dbname=elink user=elink password=elink');
3、評估結果
剛剛從bdr改過來,各類BUG、報錯不少,用的人也少暫時不考慮了