postgresql复制参考

1.创建复制用户:
CREATE USER repl WITH replication login password 'repl';

2.编辑recovery文件:
cat /pgdata/10/data/recovery.conf
standby_mode = 'on'
primary_conninfo = 'host=192.168.56.202 port=5432 user=postgres application_name=db3 user=repl password=repl keepalives_idle=60 keepalives_interval=5 keepalives_count=5'
restore_command = ''
recovery_target_timeline = 'latest'

3.在db3上执行,ip:192.168.56.203:
pg_basebackup -D /pgdata/10/data -F p -X stream -h 192.168.56.202 -p 5432 -U repl

4.启动数据库:
pg_ctl start

5.
主库检查复制状态:
select * from pg_stat_replication;

备库:
ps -ef |grep postgres |grep receiver

主库:
ps -ef |grep postgres |grep sender

备注:
如果使用pha4pgsql,检查登录分布式事务,保证无密码可以登录:
psql -U postgres -h 10.11.55.31 -p 5432 -d postgres

上一篇:pgloader 学习(九) pg 2 pg 使用with 参数控制同步逻辑


下一篇:django http转换为https