Configuration·PostgreSQL
PostgreSQL Replication Prerequisites
Four things before a standby exists: the right wal_level (already the default), a role with REPLICATION, a pg_hba rule for the special replication database, and a slot so the primary keeps the WAL the standby will need.
Replication Guide 26 of 47 Intermediate
- OSUbuntu 26.04 LTS
- PostgreSQL18.6-0ubuntu0.26.04.1
- ReplicationPhysical streaming, async, with slots
- TimeAbout 14 min
wal_level = replica and max_wal_senders = 10 are defaults, so a stock PostgreSQL is already able to feed a standby - unlike older versions where this section was mostly about turning things on.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| db-a01 | 192.168.0.81 | Ubuntu 26.04 LTS | Primary / Source / Replica Set Member 1 | 2 Core | 4 GB | 50 GB |
This guide includes
Use this before creating a standby. This matters because four things have to be true first - and three of them already are, so the real work is a role, a rule and a slot.
- checking what is already true, which turns out to be most of it
- creating a role that can replicate and do nothing else
- adding a
pg_hbarule for the replication pseudo-database - creating a slot, so the primary keeps what the standby is going to need
Before you start
- A running primary, reachable on the network.
-
Check what is already true
-
Create a role that can replicate and nothing else
-
Add a pg_hba rule for the replication pseudo-database
-
Create a slot so the primary keeps what the standby needs