A collection of practical, hands-on guides covering PostgreSQL High Availability (HA) using Patroni, etcd, HAProxy, streaming replication, and the EDB HA stack (EFM, PEM, Barman).
These notes are written from real lab/production experience and are meant as a quick reference for setting up, operating, and troubleshooting HA PostgreSQL clusters.
- Patroni Architecture Overview — how Patroni, etcd, and PostgreSQL work together to provide automated failover.
- Patroni Installation — installing Patroni and its dependencies.
- Patroni Installation on Ubuntu — Ubuntu-specific installation steps.
- Setting Up etcd — deploying and configuring an etcd cluster for Patroni.
- Setting Up etcd 3.5 and Above — changes and considerations for newer etcd versions.
- Patroni Configuration & Bootstrapping — bootstrapping a new Patroni cluster and key configuration options.
- PostgreSQL Streaming (Physical) Replication — setting up native streaming replication.
- PostgreSQL Cascade Replication — chaining replicas to reduce load on the primary.
- PostgreSQL Synchronous vs Asynchronous Replication — trade-offs and configuration for each mode.
- Adding a New Node to a Patroni Cluster — safely scaling out an existing cluster.
- Patroni Switchover Operation — performing planned leader changes without downtime.
- Backing Up a Patroni Cluster — preserving etcd and configuration state for disaster recovery.
- Patroni + HAProxy Connection Routing — routing client traffic to the correct node using HAProxy.
- EDB EPAS HA Lab: EFM, PEM, Barman — building an HA lab using EDB Failover Manager, Postgres Enterprise Manager, and Barman.
Database administrators, SREs, and engineers who are:
- Setting up a new HA PostgreSQL environment
- Migrating from a manual failover process to Patroni
- Looking for quick, tested reference commands during cluster operations
PostgreSQL · Patroni · etcd · HAProxy · EDB Postgres Advanced Server · EFM · PEM · Barman
- Examples are based on RHEL/Ubuntu environments and PostgreSQL versions 14–16; adjust paths and package names for your specific OS and PostgreSQL version.
- These are living documents — commands, paths, and package repositories may change over time, so always cross-check against current official documentation before applying changes to production systems.
Suggestions, corrections, and pull requests are welcome. If you spot an outdated command or a broken step, please let me know
Feel free to use, share, and adapt this content for learning purposes.