This guide walks you through setting up PostgreSQL streaming replication on Ubuntu 22.04, either on a single machine (for testing) or across two separate servers (for production). By following this tutorial, you will:
- Understand how primary and replica databases interact.
- Set up a replication user and configure WAL streaming.
- Verify that the replica automatically receives updates from the primary.
- Test read/write behavior and monitor replication lag in real time.
After completing this guide, the replica database will be read-only and asynchronously follow the primary. Any inserts, updates, or deletes on the primary will appear on the replica within seconds.