- Create user replication in the master
sudo -u postgres psql -c "CREATE USER rep REPLICATION \
LOGIN ENCRYPTED PASSWORD 'thepassword';"- Modify
postgresql.confin the master
listen_address = # make sure we're listening as appropriate
wal_level = hot_standby
max_wal_senders = 3
checkpoint_segments = 8
wal_keep_segments = 8
- Add rule to
pg_hba.confin the master
hostssl replication rep 1.2.3.4 md5
- Ensure you have ssl activated in the
postgresql.confmaster
ssl = true
- Create
server.crtandserver.keyfiles in the master if they don't exist.
Check
ls -l /var/lib/postgresql/$POSTGRES_VERSION/main/ | grep serverCreate
sudo -u postgres ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /var/lib/postgresql/$POSTGRES_VERSION/main/server.crt
sudo -u postgres ln -s /etc/ssl/private/ssl-cert-snakeoil.key /var/lib/postgresql/$POSTGRES_VERSION/main/server.key- Modify
postgresql.confin the slave
wal_level = hot_standby
max_wal_senders = 3
checkpoint_segments = 8
wal_keep_segments = 8
hot_standby = on
- As a
postgresuser clone this repo in the slave
cd /var/lib/postgresql
git clone https://gist.github.com/67da7f9aa3faf45ceb3d.git replication- Run the
replication/replicate_postgres.shscript in the slave
Add the following parameter:
If you need to backup a DB and the WAL_Segments may generate meanwhile.