- 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
Does it make sense to throw something like Wireguard into the mix when dealing with WAN to prevent your Postgres server from getting hammered due to having publicly exposed ports?