For this recipe, we should already have three PostgreSQL servers. As usual, we'll assume they are named pg1, pg2, and pg3. If pg1 is the current primary, follow these steps to switch to Consul:
- Execute this command as the postgres user on all nodes to stop Patroni, ending with the cluster leader:
pkill -f patroni
- Remove these two lines from /etc/patroni/stampede.yml on each server:
etcd: host: ...
- Add these two lines to /etc/patroni/stampede.yml on each server, remembering to substitute the proper server name:
consul: host: pg1:8500
- Beginning with the former leader (pg1), start Patroni on all servers with this command:
patroni /etc/patroni/stampede.yml \ &> /var/log/postgresql/patroni.log