Patroni

Overview

Describes setting up and running Patroni, an OpenSQL cluster manager.

Since Patroni needs to run/stop/restart PostgreSQL directly, the PostgreSQL-related parameter settings should be set as a subset of the Patroni configuration settings.

Environment configuration

Patroni has three different types of configurations.

Global Dynamic Configuration

  • These options are stored in the ETCD and applied to all cluster nodes.

  • Dynamic configuration can be set using the patronictl edit-config tool or the rest api.

  • Dynamic configuration changes are reflected asynchronously to all nodes.

Local Configuration File (patroni.yml)

  • Dynamic reload without restarting patroni after modifying patroni.yml

    • SIGHUP to Patroni process causes local config file to be reread

    • POST /reload REST-API

    • Use Spatronictl reload command

Environment Variables

Some local configuration parameters can be set and overridden with environment variables.

This manual describes setting up and running with a Local Configuration File of the three methods.

Local Configuration File

When the Patroni process is run, it reads the settings from the yaml file located in the path entered as a parameter. You can send a SIGHUP signal to the Patroni process or send a POST /reload request to the REST API server to reload the configuration file. The path to the default template configuration file is /etc/patroni/patroni.yml. Create a yml file in that path and modify the contents of the file to suit your configuration.

  • You can define meta information for Patroni clusters, etcd connection information, logging configuration, REST API server configuration, and PostgreSQL parameter information.

  • PostgreSQL parameters can be set in Local Configuration and Global Dynamic Configuration. If there are duplicate keys, the value in Local Configuration takes precedence.

  • You can define a bootstrap.dcs entry to set the initial configuration set for the Global Dynamic

    Configuration below.

Example of Configuration File

Create a patroni.yml file for each node as below,

Change the connect_address value in the REST API part and the hosts setting in etcd3 to the node- specific ip-address address.

In case of configuring a patroni cluster with the following node addresses

  • node1 172.176.0.2

  • node2 172.176.0.3

  • node3 172.176.0.4

Execute Patroni

After creating patroni.yml, execute the patroni process with the command below on each node as shown below. The path to a valid Configuration .yml file must be entered as an argument.

Check Cluster execution

Use the command,patronictl , to check the cluster is running normally.

As shown in the example below, the Leader is running and the Replicas are streaming, which is expected during the normal cluster boot state .

Last updated