环境
系统 debian-6.0.4
主库ip:172.16.2.151
备库ip:172.16.2.36
@H_404_11@
主库上操作
设置 pg_hba.conf,添加以下
host replication postgres 172.16.2.36/32 trust
@H_404_11@
设置主库 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
@H_404_11@
备库操作
使用 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
@H_404_11@
vi postgresql.conf
设置
hot_standby = on
@H_404_11@
设置从库 recovery.conf
cp /usr/share/postgresql/9.3/recovery.conf.sample recovery.conf
@H_404_11@
修改以下参数
standby_mode = on
primary_conninfo = 'host=172.16.2.151 port=5432 user=postgres'
#trigger_file = '/var/lib/postgresql/9.3/main/'
@H_404_11@
启数据库服务
su postgres
/usr/lib/postgresql/9.3/bin/./pg_ctl -D /var/lib/postgresql/9.3/main start