Install Patroni on each node alongside PostgreSQL; choose a distributed config store (etcd, Consul, or ZooKeeper) and provide its endpoints in each node's patroni.yml
Bootstrap the cluster: on the intended primary set bootstrap.dcs.postgresql and define synchronous_mode, maximum_lag_on_failover, and use_pg_rewind: true in the patroni.yml
Start all Patroni processes; confirm cluster health with patronictl -c /etc/patroni.yml list — all replicas should show state=running, role=replica
For a planned switchover run: patronictl -c /etc/patroni.yml switchover --master <current-leader> --candidate <preferred-new-leader>; traffic is redirected by HAProxy or the VIP layer that watches the Patroni REST endpoint
For an unplanned failover Patroni automatically elects a new leader; after the old primary recovers, Patroni uses pg_rewind to resync it as a standby without a full base backup
Monitor via the REST endpoint (GET /patroni) and configure DCS TTL and loop_wait to control detection latency
Known gotchas
With asynchronous replication, maximum_lag_on_failover limits which replicas are eligible but does not guarantee zero data loss; use synchronous_mode for transactions that must not be lost
use_pg_rewind requires the primary to have wal_log_hints=on or data checksums enabled; without it a fallen primary must be re-cloned from scratch
The DCS is a single point of failure for Patroni's quorum; ensure your etcd or Consul cluster is itself highly available across failure domains
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp