wal_level = hot_standby max_wal_senders = 1 checkpoint_segments = 8 wal_keep_segments = 8 listen_addresses = 'localhost,192.168.56.101'
This article is licensed under a Creative Commons, Attribution, Share Alike license.
Many PostgreSQL 9.0 replication tutorials set up both log shipping and streaming replication. One of the advantages of streaming replication is that it is much simpler to set up than log shipping, so this overview focuses only on streaming replication.
These instructions assume that your master / slave configuration is as follows; adjust accordingly to match your environment:
To set up streaming replication for Evergreen, perform the following steps:
wal_level = hot_standby max_wal_senders = 1 checkpoint_segments = 8 wal_keep_segments = 8 listen_addresses = 'localhost,192.168.56.101'
createuser -P -s replicant
host replication replicant 192.168.56.102/32 md5
SELECT pg_start_backup('file_backup');
cd /var/lib/postgresql/9.0 tar cjpf master_backup.tar.bz2 main
SELECT pg_stop_backup();
/etc/init.d/postgresql stop su - postgres cd /var/lib/postgresql/9.0 rm -fr main sftp evergreen@192.168.56.102 > cd /var/lib/postgresql/9.0 > get master_backup.tar.bz2 > quit tar xjf master_backup.tar.bz2 exit
hot_standby = 'on'
standby_mode = 'on' primary_conninfo = 'host=192.168.56.101 port=5432 user=replicant password=pass'
/etc/init.d/postgresql start
Check the contents of /var/log/postgresql/postgresql-9.0-main.log; if all has gone well, you should see the messages streaming replication successfully connected to primary and consistent recovery state reached.
Now do some work on your master server and connect to the slave server to ensure that the changes are being applied to the slave.