Book Image

Troubleshooting PostgreSQL

Book Image

Troubleshooting PostgreSQL

Overview of this book

Table of Contents (17 chapters)
Troubleshooting PostgreSQL
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Making use of asynchronous replication


While point-in-time recovery is nice, it might not be enough. In many cases, people want an up-to-date standby server that can also serve as a read-only slave. A feature called streaming replication is exactly what is needed in this case.

Setting up streaming replication is easy and can be performed in a handful of steps:

  1. Adapt postgresql.conf on the master server.

  2. Change pg_hba.conf to allow remote base backups.

  3. Run pg_basebackup to get an initial copy.

  4. Fire up the slave.

To set up postgresql.conf, the following settings are needed:

wal_level = hot_standby
max_wal_senders = 5
hot_standby = on

The first two settings are mandatory on the master. The wal_level field tells the server to create enough xlog to allow streaming replication, and max_wal_senders will indicate the number of streams the master is allowed to keep open.

Tip

If you are planning to run one slave, consider setting max_wal_senders to 3 or higher. During streaming, only one wal-sender process...