Skip to main content

Environment & Prerequisites

Servers

You need four Linux servers (Ubuntu 24.04 LTS or 26.04 — this guide uses the PGDG repository, which supports both). Each needs a sudo-capable user and outbound internet access for package installation.

Hostname Role Example IP vCPU RAM Disk
pg-sv01 PostgreSQL + Patroni + etcd 10.100.100.104 2 4 GB 32 GB
pg-sv02 PostgreSQL + Patroni + etcd 10.100.100.105 2 4 GB 32 GB
pg-sv03 PostgreSQL + Patroni + etcd 10.100.100.106 2 4 GB 32 GB
pg-haproxy HAProxy entry point 10.100.100.103 2 2 GB 20 GB

Adjust IPs to your network — the rest of the guide uses the values above.

Name resolution

Patroni and etcd refer to nodes by name, so add static entries to /etc/hosts on all four servers:

sudo tee -a /etc/hosts >/dev/null <<'EOF'
10.100.100.103  pg-haproxy
10.100.100.104  pg-sv01
10.100.100.105  pg-sv02
10.100.100.106  pg-sv03
EOF

(If you manage DNS, A-records work just as well.)

Network ports

Open these between the nodes (we configure UFW per component as we go):

Port Component Direction
2379 etcd client API among the 3 DB nodes + Patroni
2380 etcd peer among the 3 DB nodes
5432 PostgreSQL DB nodes ↔ each other (replication) + from HAProxy
8008 Patroni REST API from HAProxy (health checks) + admin
5432 / 5433 HAProxy RW / RO from your application clients
7000 HAProxy stats (optional) from admins

Time sync

Make sure NTP/chrony is running on every node — replication and leader leases depend on reasonably accurate clocks. On Ubuntu, systemd-timesyncd is active by default.