postgresql-9.3 流复制简单搭建

前端之家收集整理的这篇文章主要介绍了postgresql-9.3 流复制简单搭建前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

环境

系统 debian-6.0.4

数据库 postgresql-9.3.0

主库ip:172.16.2.151

备库ip:172.16.2.36


主库上操作

设置 pg_hba.conf,添加以下

host replication postgres 172.16.2.36/32 trust


设置主库 postgresql.conf

wal_level = hot_standby

checkpoint_segments = 16

archive_mode = on

archive_command = 'cp -f %p /var/lib/postgresql/9.3/wal.backup/%f'

max_wal_senders = 3

wal_keep_segments = 16


备库操作

使用 pg_basebackup 生成备库

root@localhost:/var/lib/postgresql/9.3/main# pg_basebackup -D /var/lib/postgresql/9.3/main -Fp -Xs -v -P -h 172.16.2.151 -p 5432 -U postgres

transaction log start point: 0/6C000028 on timeline 1

pg_basebackup: starting background WAL receiver

400749/400749 kB (100%),1/1 tablespace

transaction log end point: 0/6C0000F0

pg_basebackup: waiting for background process to finish streaming ...

pg_basebackup: base backup completed


vi postgresql.conf

设置

hot_standby = on


设置从库 recovery.conf

cp /usr/share/postgresql/9.3/recovery.conf.sample recovery.conf


修改以下参数

standby_mode = on

primary_conninfo = 'host=172.16.2.151 port=5432 user=postgres'

#trigger_file = '/var/lib/postgresql/9.3/main/'


数据库服务

su postgres

/usr/lib/postgresql/9.3/bin/./pg_ctl -D /var/lib/postgresql/9.3/main start

原文链接:https://www.f2er.com/postgresql/196023.html

猜你在找的Postgre SQL相关文章