Skip to content

Instantly share code, notes, and snippets.

@zhangchunlin
Created December 4, 2015 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhangchunlin/5f1bed1cce94852f0346 to your computer and use it in GitHub Desktop.
Save zhangchunlin/5f1bed1cce94852f0346 to your computer and use it in GitHub Desktop.
postgresql hot standby replication
[1]
listen_addresses = 'localhost,IP_address_of_THIS_host'
wal_level = 'hot_standby'
archive_mode = on
archive_command = 'cd .'
max_wal_senders = 1
hot_standby = on
[2]
host replication rep 10.125.159.101/32 md5
[3]
host replication rep IP_address_of_slave/32 md5
[4]
listen_addresses = 'localhost,IP_address_of_THIS_host'
wal_level = 'hot_standby'
archive_mode = on
archive_command = 'cd .'
max_wal_senders = 1
hot_standby = on
[5]
psql -c "select pg_start_backup('initial_backup');"
rsync -cva --inplace --exclude=*pg_xlog* --exclude postmaster.pid --exclude server.* /var/lib/postgresql/9.1/main/ postgres@bjmirr:/var/lib/postgresql/9.1/main/
psql -c "select pg_stop_backup();"
[6]
sudo - postgres
pg_basebackup -h 10.125.159.101 -p 5432 -D /var/lib/postgresql/9.1/backup -U rep -v -P -x
[7]
vim /var/lib/postgresql/9.1/main/recovery.conf
standby_mode = 'on'
primary_conninfo = 'host=10.125.159.101 port=5432 user=rep password=xxx'
trigger_file = '/tmp/postgresql.trigger.5433'
[8]
kernel.shmmax = 536870912
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment