pglogical 2.2.0配置说明
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pglogical 2.2.0配置说明相关的知识,希望对你有一定的参考价值。
master: postgresql 9.5(192.168.31.205)standby: postgresql 10.3(192.168.31.202)
1.postgresql配置
1).vi postgresql.conf
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+
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
postgres=# SELECT pglogical.create_node(
postgres(# node_name := ‘provider1‘,
postgres(# dsn := ‘host=192.168.31.205 port=5432 dbname=postgres‘
postgres(# );
create_node
2976894835
(1 row)
postgres=# SELECT pglogical.replication_set_add_all_tables(‘default‘, ARRAY[‘public‘]);
replication_set_add_all_tables
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
postgres=# SELECT pglogical.create_node(
node_name := ‘subscriber1‘,
dsn := ‘host=192.168.31.202 port=5432 dbname=postgres‘
);
create_node
330520249
(1 row)
postgres=# select * from pglogical.node;
node_id | node_name
-----------+-------------
330520249 | subscriber1
(1 row)
postgres=# SELECT pglogical.create_subscription(
subscription_name := ‘subscription1‘,
provider_dsn := ‘host=192.168.31.205 port=5432 dbname=postgres password=123456‘
);
create_subscription
1763399739
(1 row)
postgres=#
以上是关于pglogical 2.2.0配置说明的主要内容,如果未能解决你的问题,请参考以下文章