4 min read

8 Patroni commands every DBA should Know

Patroni has command line utility patronictl which can be used to interact with the Patroni postgres cluster. Let's see patroni commands every DBA should know.
8 Patroni commands every DBA should Know
Useful patronictl commands - For managing Postgres with Patroni

As an open source software, Postgres does not have an enterprise-grade, foolproof high availability solution like Oracle or DB2. To achieve high availability, it is necessary to utilize various open source solutions.

Patroni, however, provides a comprehensive solution for setting up a production Postgres cluster with both high availability and disaster recovery capabilities.

Patroni comes with CLI utility called as patronictl. One can perform any admin operation related to Postgres database or cluster using this command line utility.

Table of contents

patronictl edit-config

To edit postgres configuration parameters you can use edit-config command. It will open configuration file in editor, make the required changes and Patroni will validate all parameters before saving configuration file.

You can also add pg_hba entries to the configuration so these will be reflected all over the cluster.

If you directly update parameter values in Postgres configuration files it will be overwritten via Patroni configuration if same parameter is explicitly defined in patroni config.

When to use: If you want to change some postgres parameter, add/remove pg_hba entries - you can use patronictl edit-config command

How to use:

# /etc/patroni/patroin.yaml is configuration file for patroni
patronictl -c /etc/patroni/patroni.yaml edit-config

patronictl edit-config

E-Book: Patroni Administration & Commands
Master Patroni Commands and administration using this completely free ebook!

patronictl reload

This command will reload parameters from configuration file and takes required action like restart on cluster nodes.

When to use: If you have changed parameters in configuration file using edit-config you can use reload command for parameters to take effect

How to use:

 # patroni_cluster is name of your cluster
 patronictl -c /etc/patroni/patroni.yaml reload patroni_cluster

patronictl switchover

It will make selected replica as master node basically will switch all traffic to new selected node. We can have planned switchover at particular time as well.

When to use: If you have maintenance for master node you can switchover master to another node in the cluster.

How to use:

# It will ask for node to switchover and also time for switchover
patronictl -c /etc/patroni/patroni.yaml switchover

patronictl pause

Patroni will stop managing postgres cluster and will turn on the maintenance mode. If you want to do some manual activities for maintenance you need to stop patroni from auto managing cluster.

When to use: If you want to put cluster in maintenance mode and manage Postgres database manually for some time, you can use pause command so that Patroni will stop managing the cluster

How to use:

patronictl -c /etc/patroni/patroni.yaml pause

patronictl resume

It will start the paused cluster management and remove the cluster from maintenance mode

When to use: If you want to turn off maintenance mode, you can use resume command and patroni will start managing the cluster

How to use:

patronictl -c /etc/patroni/patroni.yaml resume

patronictl list

List all nodes and it's role, status. You can use it for checking status of all nodes, which is the master and which all are slaves/replicas.

When to use: To check list and status of all nodes in the cluster, you can get all the information about nodes including if any restart is required for any node

How to use:

patronictl -c /etc/patroni/patroni.yaml list

patronictl restart

It will restart single node in the postgres cluster or all nodes(complete cluster). Patroni will do the rolling restart for postgres on all nodes.

When to use: Sometimes you need to restart all nodes in the cluster without downtime, you can use this command for rolling restart

How to use:

# Restart particular node in cluster
patronictl -c /etc/patroni/patroni.yaml restart <CLUSTER_NAME> <NODE_NAME>

# Restart whole cluster(all nodes in cluster)
patronictl -c /etc/patroni/patroni.yaml restart <CLUSTER_NAME>

patronictl reinit

It will reinitialize node in the cluster. If you want to reinitialize particular replica or slave node you can reinitialize node using reinit command.

When to use: patronictl reinit command allows you to reinitialize a specific node and can be utilized when a cluster node experiences failure in starting or displays an unknown status for the node in the cluster . It is often useful in cases where a node has corrupt data.

How to use:

patronictl -c /etc/patroni/patroni.yaml reinit <CLUSTER_NAME> <NODE_NAME>


Instead of using -c /etc/patroni/patroni.yaml with patronictl you can set alias in your .profile file

alias patronictl='patronictl -c /etc/patroni/patroni.yaml'

Master Patroni Commands Now! 🚀 Unlock the Full Guide for Advanced Strategies and Pro Tips. Sign up to Download the Ebook – It's Free!


In summary, Patroni offers a set of commands for administering a PostgreSQL cluster. With Patroni, you can handle all maintenance and management tasks for your PostgreSQL database without having to manage it separately.

For more information on Patroni cluster manager you can visit official patroni documentation