PostgreSQL配置Streaming Replication叢集

來源:互聯網
上載者:User

運行環境: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目錄下的內容為  更多詳情見請繼續閱讀下一頁的精彩內容:
  • 1
  • 2
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.