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:
Adapt
postgresql.conf
on the master server.Change
pg_hba.conf
to allow remote base backups.Run
pg_basebackup
to get an initial copy.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...