postgres master
1. 創(chuàng)建復制用戶
CREATE ROLE repl login replication encrypted password 'xx'
2.訪問控制 pg_hba.conf
host replication repl 10.45.184.xxx/32 trust
3.啟用熱備postgres.conf
wal_level = hot_standby
fsync = on
wal_sync_method = fsync
postgres salve
4.copy 基礎備份
創(chuàng)建基礎備份目錄
注明:該目錄為后面postgres 服務啟動的數(shù)據(jù)目錄,權限為077 一般會在copy后自動幫你修改
mkdir -p /opt/pgsql/cluster/data
pg_basebackup -F p --progress -D /opt/pgsql/cluster/data -h 10.24.247.master -p 5432 -U repl --password
5.修改copy過來的配置
在/opt/pgsql/cluster/data中找到postgres.conf
listen_addresses = '10.24.xx.slave'
hot_standby = on
max_standby_archive_delay = 30s
max_standby_streaming_delay = 30s
wal_receiver_status_interval = 10s
hot_standby_feedback = on
wal_receiver_timeout = 60s
wal_retrieve_retry_interval = 5s
6.配置recovery.conf
從postgres_home/share 復制 recovery.conf.sample 到/opt/pgsql/cluster/data
命令: cp /opt/pgsql/share/recovery.conf.sample /opt/pgsql/cluster/data/recovery.conf
修改內容為
recovery_target_timeline = 'latest'
standby_mode = on
primary_conninfo = 'host=10.25.210.master port=5432 user=repl password=xxx'