Setting up asynchronous replication
The idea behind streaming replication is simple. After an initial base backup, the secondary backup can connect to the primary, fetch a transaction log in real time, and apply it. Transaction log replay isn’t a single operation anymore but rather a continuous process that’s supposed to keep running for as long as a cluster exists.
Performing a basic setup
In this section, we’ll learn how to set up asynchronous replication quickly and easily. The goal is to set up a system that consists of two nodes.
Most of the work has already been done for WAL
archiving. However, to make it easy to understand, we’ll look at the entire process of setting up streaming because we can’t assume that WAL
shipping has already been set up as needed.
The first thing we must do is go to the postgresql.conf
file and adjust the following parameters:
wal_level = replica max_wal_senders = 10 # or whatever value...