标签:pglogical
master: postgresql 9.5(192.168.31.205)1.postgresql配置
1).vi postgresql.conf
wal_level = ‘logical‘
max_worker_processes = 10 # one per database needed on provider 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
2).pg_hba.conf
pg_hba.conf has to allow replication connections from localhost.
--# replication privilege.
#local replication postgres trust
#host replication postgres 127.0.0.1/32 trust
#host replication postgres ::1/128 trust
host replication postgres 192.168.31.0/24 trust
2.pglogical安装
source
https://github.com/2ndQuadrant/pglogical/releases
1).install
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/pgsql/9.5/bin
make USE_PGXS=1 clean all
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/pgsql/9.5/bin
make USE_PGXS=1 install
2).create extention
(master/standby)
CREATE EXTENSION pglogical;
3.pglogical配置
master/standby
create table t1(id serial primary key, name varchar(20));
1).master
2976894835
(1 row)
t
(1 row)
postgres=#
postgres=# select * from pglogical.node_interface;
if_id | if_name | if_nodeid | if_dsn
------------+-----------+------------+-----------------------------------------------
2402836775 | provider1 | 2976894835 | host=192.168.31.205 port=5432 dbname=postgres
(1 row)
postgres=# create table t1(id serial primary key, name varchar(20));
2).standby
330520249
(1 row)
postgres=# select * from pglogical.node;
node_id | node_name
-----------+-------------
330520249 | subscriber1
(1 row)
1763399739
(1 row)
postgres=#
标签:pglogical
原文地址:http://blog.51cto.com/heyiyi/2092084