【转载】主备环境搭建

【环境】
zhuji 192.168.3.139
beiji 192.168.3.204
create user repuser with login replication password '123456';

【主机】
1)修改pg_hba.conf
host replication repuser 192.168.3.139/32 md5
host replication repuser 192.168.3.204/32 md5
host all postgres 192.168.3.139/32 trust
host all postgres 192.168.3.204/32 trust

2)设置postgresql.conf
wal_level = replica
wal_log_hints = on
wal_keep_segments = 10
hot_standby_feedback = on
listen_addresses='192.168.3.139'

3)重启主机
4)创建复制槽
select * from pg_create_physical_replication_slot('postgresql_node102');


【备机】
0) 删除data目录
rm -rf data/*

1)基础备份
pg_basebackup -Xs -d "hostaddr=192.168.3.139 port=5432 user=repuser password=123456" -D /home/jiang/pg11/data -v -Fp

2)修改postgresql.conf
hot_standby = on

3)修改recovery.conf
cp ./project/share/postgresql/recovery.conf.sample data/recovery.conf
recovery_target_timeline = 'latest'
standby_mode = on
primary_conninfo = 'host=192.168.3.139 port=5432 user=repuser password=123456'
primary_slot_name = 'postgresql_node102'
trigger_file = 'tgfile'

4) 启动备机

【参考】
https://www.cnblogs.com/xianghuaqiang/p/14791994.html

上一篇:HBase——Replication(复制)实践


下一篇:java函数调用方法,统统都会!