How to do it...

For this scenario, the server at 192.168.56.10 is the primary PostgreSQL server, and 192.168.56.20 will be the new copy. Once again, arc_server will be the location of the archive server with old WAL files. On all PostgreSQL servers, our data directory should be located at /db/pgdata.

Follow these steps to build a PostgreSQL hot standby:

  1. Ensure that the pg_hba.conf file on the primary server contains this line:
        host   replication   rep_user   192.168.56.20/32   trust 
  1. Ensure that the wal_level and max_wal_senders settings in postgresql.conf are set as follows on the primary server:
        wal_level = replica 
        max_wal_senders = 5 
  1. Restart PostgreSQL on the primary server with the following command as the postgres user:
        pg_ctl -D /db/pgdata ...

Get PostgreSQL High Availability Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.