Table of Contents

Standby Server Replication - PostgreSQL 9.1

Prepare STANDBY Server

    service postgresql stop

On MASTER Server

    host all all <IP_OF_STANDBY_SERVER> <NETMASK_OF_STANDBY_SERVER> trust
    listen_addresses = '*'
    hot_standby = on
    max_wal_senders = 1
    wal_level = 'hot_standby'
    archive_mode = on
    archive_command = 'cd .'
    wal_keep_segments = 1000
    service postgresql restart
    ssh-keygen
    ssh-copy-id <IP_OF_STANDBY_SERVER>
    BACKUP_LABEL="base-backup"
    PORT="5432"
    PGDATA="/var/lib/pgsql/data" 

    psql -p $PORT -c "select pg_start_backup('$BACKUP_LABEL');"
    rsync -cva --inplace --exclude=*pg_xlog* $PGDATA/ <IP_OF_STANDBY_SERVER>:$PGDATA/
    psql -p $PORT -c "select pg_stop_backup();"

On STANDBY Server

    standby_mode = 'on'
    primary_conninfo = 'host=<IP_OF_MASTER_SERVER> user=postgres'
    trigger_file = '/tmp/postgresql.trigger.$PORT'
    service postgresql start
    cat /var/lib/pgsql/data/pg_log/*