Setting up an asynchronous replication

After going through the transaction log related issues, it is time to set up the asynchronous replication. The process itself is pretty simple. However, it is important to gain some overview of the problem.

Obtaining a high-level overview

So, before digging into details, I would like to list the steps necessary to set up a streaming replication slave.

Note

Slaves are always read-only. Writes are not allowed on slaves.

The steps are as follows:

  1. Install PostgreSQL and create a data directory in the slave as follows:
    • mkdir /data # for example
    • chmod 700 /data # to start PostgreSQL
    • chown postgres.postgres /data # if running as postgres
  2. Edit postgresql.conf in the master:
    • Set wal_level to hot_standby
    • Set max_wal_senders to ...

Get PostgreSQL Administration Essentials 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.