How it works...

We were serious when we said this recipe would be fairly simple. By calling patronictl with the failover parameter, we're telling it that we definitely want to promote another node to primary status. The -d flag allows us to specify etcd as a configuration source, and is usually the safer option since it should always reflect the current state of the cluster.

Our example targeted the pg1 server on the etcd port of 2379, but we could have used any of the cluster systems. Since the distributed key-value system may play host to any number of clusters, we must also specify stampede as the name of the cluster we want to manage.

Once we invoke the failover command, Patroni asks multiple questions to verify the process to make absolutely ...

Get PostgreSQL High Availability Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.