Book Image

PostgreSQL Administration Essentials

Book Image

PostgreSQL Administration Essentials

Overview of this book

Table of Contents (14 chapters)

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 a reasonably high number

    • Set hot_standby to on (for making things easier later on)

  3. Edit pg_hba.conf in the master and add replication rules to make sure remote boxes can connect to your server.

  4. Restart PostgreSQL on the master...