運行環境:Primary: 192.168.111.150Standby: 192.168.111.151192.168.111.152OS: CentOS5.8PostgreSQL: 9.1.2 版本以上才支援Streaming Replication。
PostgreSQL緩衝詳述
Windows平台編譯 PostgreSQL
Ubuntu下LAPP(Linux+Apache+PostgreSQL+PHP)環境的配置與安裝
Ubuntu上的phppgAdmin安裝及配置
CentOS平台下安裝PostgreSQL9.3
1. 環境規劃Primary和Standby節點最好有相同的環境。 2. 安裝PostgreSQL1)在Primary和Standy節點上安裝PostgreSQL軟體,安裝路徑為/opt/pgsql-9.1.22)設定postgres使用者的環境變數PGHOME=/opt/pgsql-9.1.2PGDATA=/storage0/database/postgres/mainPATH=$PG_HOME/bin:$PATH:$HOME/bin 3. Primary節點1)切換到postgres使用者$su - postgres2)初始化資料庫$initdb3)配置pg_hba.conf在# IPv4 local connections下面添加一行,設定PostgreSQL的訪問及其許可權host all all 192.168.111.1/24 trust在# replication privilege.下面添加一行,設定replication使用者及許可權host replication postgres 192.168.111.1/24 trust4)配置postgresql.conf配置監聽,修改listen_addresses = 'localhost'listen_addresses = '*'# what IP address(es) to listen on;配置Primary Replication參數wal_level = hot_standbymax_wal_senders = 5wal_keep_segments = 32archive_mode = onarchive_command = 'cp %p /storage0/database/postgres/archive/%f < /dev/null'"/storage0/database/postgres/archive"是Replication的archive的儲存路徑。PostgreSQL會將Replication的WAL儲存在 "/storage0/database/postgres/archive"路徑下。5) 啟動Primary上的PostgreSQL資料庫$pg_ctl start6) 在primary上執行以下命令$psql -c "SELECT pg_start_backup('label', true)"將Primary的PGDATA目錄下的檔案,除了postmaster.pid複製到Standby節點的“/storage0/database/postgres/main”目錄下,該目錄是 Standby節點上的PostgreSQL資料庫的PGDATA目錄。$rsync -a ${PGDATA}/ postgres@192.168.111.151:/storage0/database/postgres/main --exclude postmaster.pid$psql -c "SELECT pg_stop_backup()" 192.168.111.151的/storage0/database/postgres/main目錄下的內容為 更多詳情見請繼續閱讀下一頁的精彩內容: