postgres 主從配置

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'                

copy from http://www.cnblogs.com/yjf512/p/4499547.html

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容