Patroni

patronictl is a Python 3-based CLI (command line interface) installed with the Patroni package, which provides functions for monitoring clusters and accessing DCS using the REST API provided by Patroni clusters.

Used to manage PostgreSQL clusters, check their status, and verify configuration settings.

Check Installation

patronictl is provided by default with the Python 3 package patroni. You can check whether patronictl is installed on the node and its version as follows.

$ which patronictl 
/usr/local/bin/patronictl

$ patronictl version
patronictl version 3.3.0


Configure Local Configuration File

This is a configuration value that is read from a yml file located in the path that is input as a parameter when the Patroni process runs.

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 environment configuration file is /etc/patroni/patroni.yml. Create a yml file in that path and modify the contents of the file to suit the environment you want to configure

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

  • The PostgreSQL parameter set is defined in the Local Configuration and Global Dynamic. If there are duplicate keys, the value in the Local Configuration takes precedence.

  • Configuration below. Define the bootstrap.dcs item to set the initial configuration set for Global Dynamic Configuration below.

Cluster meta information

scope: batman
#namespace: /service/
name: postgresql0
  • scope: the Patroni cluster you want to configure. PostgreSQL parameters Applied to cluster_name.

  • namespace: Prefix of the key to use within the Configuration Store.

  • name: The name of this instance (node). Must be unique within the cluster; if not set, the hostname is used.

Logging

log:
  type: plain
  format: "[%(asctime)s] [%(module)s] [%(levelname)s]: %(message)s"
  dir: /etc/patroni/logs
  • log.type: Specifies the log format. Two options are supported: plain and json. Using the json

    type requires an additional installation of the Python package patroni[jsonlogger].

  • log.format: Specify the format of the log messages. Use the LogRecord module of the Python

    logging package. ◦If the log type is plain, it should be given as a string like the example above. ◦If the log type is json, it can be given as an array of items to be logged. ◦See https://docs.py thon.org /3.6/library /logg ing .html#logrecord-attributes ◦log.dir: The path to the directory where Patroni logs will be written, and the default retention for log files. The size is 425 MB. ◦For items not mentioned, see the documentation at the links below; https://patroni.readthedocs.io/en/latest/ENVIRONMENT.html#log

Rest API

restapi:
  listen: 0.0.0.0:8008
  connect_address: 192.168.0.100:8008
  • restapi.listen: The IPv4 address and port number to which the Patroni REST API server will be bound.

  • restapi.connect_address: The externally identifiable Rest API server address of this node to use for communication between Patroni members. This value is also parsed and used as the Host address when making API calls to lookup cluster members.

DCS (etcd)

Example for etcd v3

etcd3:
  protocol: http
  # host: 192.168.0.100:2379
  hosts:
  - 192.168.0.1:2379
  - 192.168.0.2:2379
  - 192.168.0.3:2379
  • etcd3.protocol: Supports http or https as the protocol to use when accessing the etcd3 cluster. http is used as the default value, and if it is https, you need to set etcd3.cacert , etcd3.cert , etcd3.key additionally.

  • etcd3.host: etcd3 endpoint URL

  • etcd3.hosts: Array of etcd3 cluster endpoint URLs

Bootstrapping

If a PostgreSQL database is not initialized on the node when Patroni starts, use the information in this section to initialize a database instance. If there is an already configured PostgreSQL database on the node, the contents of this section or any changes you add will not be reflected in Patroni.

The contents of the sub-item bootstrap.dcs initialize the Patroni cluster and are the values that will be stored in the DCS as Global Dynamic Configuration.

bootstrap:
  # This section will be written into Etcd:/<namespace>/<scope>/config after initializing new cluster
  # and all other cluster members will use it as a `global configuration`.
  # WARNING! If you want to change any of the parameters that were set up
  # via `bootstrap.dcs` section, please use `patronictl edit-config`!
  dcs:
    ttl: 30
    loop_wait: 10
    retry_timeout: 10
    maximum_lag_on_failover: 1048576
#    primary_start_timeout: 300
#    synchronous_mode: false
    #standby_cluster:
      #host: 127.0.0.1
      #port: 1111
      #primary_slot_name: patroni
    slots:
      barman:
        type: physical
    postgresql:
      use_pg_rewind: true
      use_slots: true
      parameters:
#        wal_level: hot_standby
#        hot_standby: "on"
        max_connections: 100
        max_worker_processes: 8
#        wal_keep_segments: 8
#        max_wal_senders: 10
#        max_replication_slots: 10
#        max_prepared_transactions: 0
#        max_locks_per_transaction: 64
#        wal_log_hints: "on"
#        track_commit_timestamp: "off"
#        archive_mode: "on"
#        archive_timeout: 1800s
#        archive_command: mkdir -p ../wal_archive && test ! -f ../wal_archive/%f && cp %p ../wal_archive/%f
#      recovery_conf:
#        restore_command: cp ../wal_archive/%f %p

  # some desired options for 'initdb'
  initdb:  # Note: It needs to be a list (some options need values, others are switches)
  - encoding: UTF8
  - data-checksums
  • bootstrap.dcs: When When initializing with Patroni cluster preferences, this is the Global Dynamic Configuration set stored in /<namespace>/<scope>/config in DCS.

  • bootstrap.initdb: If you set initdb (default) as the database initialization method, this is an array of parameters to pass to initdb when it is run.

PostgreSQL

Defines system parameters, default users, host-based authentication rules, database parameters, and other settings for the PostgreSQL database.

The key in the Global Dynamic Configuration is the same as the one specified by postgresql. If the same key is defined twice in this file and in the Global Dynamic Configuration, the value defined in this file (i.e., the Local Configuration File) takes precedence.

postgresql:
  listen: 0.0.0.0:5432
  connect_address: 192.168.0.100:5432
  proxy_address: 127.0.0.1:6432  # The address of connection pool (e.g., pgbouncer) running next to Patroni/Postgres. Only for service discovery.
  #data_dir: data/postgresql0
  data_dir: /var/lib/pgsql/16/data
  bin_dir: /usr/pgsql-16/bin
#  config_dir:
  pgpass: /tmp/pgpass0
  authentication:
    replication:
      username: patroni_repl
      password: patroni_repl
    superuser:
      username: postgres
      password: zalando
    rewind:  # Has no effect on postgres 10 and lower
      username: patroni_rewind
      password: patroni_rewind
  pg_hba:
  # For kerberos gss based connectivity (discard @.*$)
  - local all all trust
  - host replication patroni_repl 192.168.0.0/24 trust
  - host replication patroni_repl 127.0.0.1/32 trust
  - host all all 0.0.0.0/0 md5
  - host all barman 192.168.0.0/24 trust
  - host replication streaming_barman 192.168.0.0/24 trust
  parameters:
    log_line_prefix: '%m [%r] [%u] [%a]'
    archive_command: 'barman-wal-archive node4 pg %p'
    archive_mode: 'true'
    wal_level: 'replica'
  • postgresql.listen: Enter the address for the PostgreSQL server to be run by Patroni on this node to listen to in the form of <IP address>:<Port number> .

  • postgresql.connect_address: Enter the connection URL of PostgreSQL to be referenced by other nodes or client applications. This is the value returned when retrieving cluster information and DSN.

  • postgresql.proxy_address: If you have a proxy server to access the PostgreSQL server, you can enter the URL of that proxy server for service discovery as needed, and this value is stored with the cluster information in DCS.

  • postgresql.data_dir: The data path to the PostgreSQL server. The user running the Patroni process must have access to this path. If this path is empty, the Patroni process will run with the initdb behavior.

  • postgresql.bin_dir: Specifies the path where the PostgreSQL executable binaries pg_ctl, initdb, postgres, etc. are located.

  • postgresql.config_dir: Path to the directory to hold the PostgreSQL configuration file

    postgresql.conf. The default value is the same as the data_dir value.

  • postgresql.pg_hba: Enter items to write to the pg_hba.conf file (PostgreSQL's default host-based authentication settings) that Patroni will create. This entry is ignored if the PostgreSQL parameter hba_file is set to a custom value.

  • postgresql.parameters: PostgreSQL database parameters. They are entered in key-value format a n d are used when generating the postgresql.conf file.


Usage

patronictl does not store any configuration settings and must be given a DCS connection URL or Patroni connection URL to get information about the cluster on each run.

$ patronictl list
2024-10-29 17:20:56,603 - WARNING - Listing members: No cluster names were provided 

$ patronictl list opensql
Error: Can not find suitable configuration of distributed configuration store
Available implementations: etcd, etcd3, kubernetes

Use the Configuration .yml file that you used to configure the cluster as an argument as shown below.

$ patronictl -c /etc/patroni/patroni.yml list

+ Cluster: opensql (7364637789542980847) ----------+----+-----------+------------------------+ 
| Member      | Host        | Role    | State     | TL | Lag in MB | Tags                   | 
+-------------+-------------+---------+-----------+----+-----------+------------------------+ 
| postgresql0 | 192.1.1.218 | Replica | streaming | 16 |         0 |                        | 
+-------------+-------------+---------+-----------+----+-----------+------------------------+ 
| postgresql1 | 192.1.1.236 | Replica | streaming | 16 |         0 | failover_priority: 150 | 
|             |             |         |           |    |           | nofailover: false      | 
+-------------+-------------+---------+-----------+----+-----------+------------------------+ 
| postgresql2 | 192.1.1.238 | Leader  | running   | 16 |           |                        | 
+-------------+-------------+---------+-----------+----+-----------+------------------------+

You can also register with a Linux alias as shown below.

$ alias pctl='patronictl -c /etc/patroni/patroni.yml'

$ echo 'alias pctl="patronictl -c /etc/patroni/patroni.yml"' >> ~/.bashrc

$ pctl list
+ Cluster: opensql (7364637789542980847) ----------+----+-----------+------------------------+
| Member      | Host        | Role    | State     | TL | Lag in MB | Tags                   |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql0 | 192.1.1.218 | Replica | streaming | 16 |         0 |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql1 | 192.1.1.236 | Replica | streaming | 16 |         0 | failover_priority: 150 |
|             |             |         |           |    |           | nofailover: false      |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql2 | 192.1.1.238 | Leader  | running   | 16 |           |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+

Check Cluster Information

Displays the configuration nodes in the cluster, as well as the connection and status information for each node.

$ patronictl list
2024-10-29 15:36:15,282 - WARNING - Listing members: No cluster names were provided

## View as a table(default)
$ patronictl -c /etc/patroni/patroni.yml list
+ Cluster: opensql (7364637789542980847) ----------+----+-----------+------------------------+
| Member      | Host        | Role    | State     | TL | Lag in MB | Tags                   |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql0 | 192.1.1.218 | Replica | streaming | 16 |         0 |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql1 | 192.1.1.236 | Replica | streaming | 16 |         0 | failover_priority: 150 |
|             |             |         |           |    |           | nofailover: false      |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql2 | 192.1.1.238 | Leader  | running   | 16 |           |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+

## View as a JSON 
$ patronictl -c /etc/patroni/patroni.yml list -f json
[{"Cluster": "opensql", "Member": "postgresql0", "Host": "192.1.1.218", "Role": "Leader", "State": "running", "TL": 17}, {"Cluster": "opensql", "Member": "postgresql1", "Host": "192.1.1.236", "Role": "Replica", "State": "streaming", "TL": 17, "Lag in MB": 0, "Tags": {"nofailover": false, "failover_priority": 150}}, {"Cluster": "opensql", "Member": "postgresql2", "Host": "192.1.1.238", "Role": "Replica", "State": "streaming", "TL": 17, "Lag in MB": 0}]

Topology Output

$ patronictl -c /etc/patroni/patroni.yml topology
+ Cluster: opensql (7364637789542980847) +-----------+----+-----------+---------------------------------------------+
| Member        | Host        | Role    | State     | TL | Lag in MB | Tags                                        |
+---------------+-------------+---------+-----------+----+-----------+---------------------------------------------+
| postgresql2   | 192.1.1.238 | Leader  | running   | 21 |           |                                             |
| + postgresql0 | 192.1.1.218 | Replica | streaming | 21 |         0 |                                             |
| + postgresql1 | 192.1.1.236 | Replica | streaming | 21 |         0 | {failover_priority: 150, nofailover: false} |
+---------------+-------------+---------+-----------+----+-----------+---------------------------------------------+

DSN Output

Outputs the DSN (Data Source Name) of the cluster node. If no separate option is specified, outputs the connection information for the leader node.

$ patronictl -c /etc/patroni/patroni.yml dsn
host=192.1.1.238 port=5432

You can also print access information for members with specific roles, or you can print access information for specific members by name.

$ patronictl -c /etc/patroni/patroni.yml dsn -r replica
host=192.1.1.218 port=5432

$ patronictl -c /etc/patroni/patroni.yml dsn -m postgresql1
host=192.1.1.236 port=5432

Restart

Restart the PostgreSQL process on one of the member nodes of the cluster. The cluster name (set in the meta information) must be given as an argument, with the name of the member node as an optional extra. If no member name is specified, all nodes are restarted once.

$ pctl restart <cluster_name>

Provides an interactive prompt to enter a restart date and time (with the option to restart immediately and the ability to schedule a restart by specifying a timestamp), and the ability to filter by checking the version of the PostgreSQL server to restart.

$ pctl restart opensql postgresql0
+ Cluster: opensql (7364637789542980847) ----------+----+-----------+------------------------+
| Member      | Host        | Role    | State     | TL | Lag in MB | Tags                   |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql0 | 192.1.1.218 | Replica | streaming | 16 |         0 |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql1 | 192.1.1.236 | Replica | streaming | 16 |         0 | failover_priority: 150 |
|             |             |         |           |    |           | nofailover: false      |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql2 | 192.1.1.238 | Leader  | running   | 16 |           |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
When should the restart take place (e.g. 2024-10-31T12:16)  [now]:
## restart immediately arter typing now

Are you sure you want to restart members postgresql0? [y/N]:

Restart if the PostgreSQL version is less than provided (e.g. 9.5.2)  []:

Success: restart on member postgresql0

Reloading

This function reloads the configuration without restarting the PostgreSQL server on one of the member nodes of the cluster. The cluster name must be given as an argument, with the name of the member node as an option.

$ pctl reload <cluster_name>

Confirm whether you want to schedule a cluster member reload through an interactive prompt.

$ pctl reload opensql
+ Cluster: opensql (7364637789542980847) ----------+----+-----------+------------------------+
| Member      | Host        | Role    | State     | TL | Lag in MB | Tags                   |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql0 | 192.1.1.218 | Replica | streaming | 16 |         0 |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql1 | 192.1.1.236 | Replica | streaming | 16 |         0 | failover_priority: 150 |
|             |             |         |           |    |           | nofailover: false      |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql2 | 192.1.1.238 | Leader  | running   | 16 |           |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
Are you sure you want to reload members postgresql0, postgresql1, postgresql2? [y/N]:
Reload request received for member postgresql0 and will be processed within 10 seconds
Reload request received for member postgresql1 and will be processed within 10 seconds
Reload request received for member postgresql2 and will be processed within 10 seconds

PostgreSQL variables (GUC) with Context values of internal and postmaster cannot be changed by the Reloading feature. The internal variable is determined when compiling the server program or when initializing the database with the initdb command and cannot be changed without reinstalling the database, and the postmaster variable can only be changed by restarting the PostgreSQL process.

View History

View the history of Failover and Switchover that occurred in the cluster.

$ pctl history
+----+------------+------------------------------+----------------------------------+-------------+
| TL |        LSN | Reason                       | Timestamp                        | New Leader  |
+----+------------+------------------------------+----------------------------------+-------------+
|  1 |   26875256 | no recovery target specified | 2024-05-03T14:20:28.841738+09:00 | postgresql2 |
|  2 |  213072680 | no recovery target specified | 2024-05-03T14:45:37.945208+09:00 | postgresql1 |
|  3 |  213101064 | no recovery target specified | 2024-05-03T14:46:14.686504+09:00 | postgresql2 |
|  4 |  805306528 | no recovery target specified | 2024-05-28T17:44:02.808722+09:00 | postgresql1 |
|  5 |  855638176 | no recovery target specified | 2024-05-28T17:54:12.358175+09:00 | postgresql2 |
|  6 | 1879048352 | no recovery target specified | 2024-07-30T15:58:10.527327+09:00 | postgresql0 |
|  7 | 1895825568 | no recovery target specified | 2024-07-30T15:58:52.408275+09:00 | postgresql2 |
|  8 | 2013266080 | no recovery target specified | 2024-08-12T10:00:38.641449+09:00 | postgresql2 |
|  9 | 2030043296 | no recovery target specified | 2024-08-12T10:04:16.370771+09:00 | postgresql2 |
| 10 | 2046820512 | no recovery target specified | 2024-08-12T10:05:07.178679+09:00 | postgresql2 |
| 11 | 2063597728 | no recovery target specified | 2024-08-12T10:47:06.368795+09:00 | postgresql2 |
| 12 | 2080374944 | no recovery target specified | 2024-08-12T10:50:59.596850+09:00 | postgresql2 |
| 13 | 2332033184 | no recovery target specified | 2024-10-28T13:41:28.936064+09:00 | postgresql1 |
| 14 | 2348810400 | no recovery target specified | 2024-10-28T16:04:27.587725+09:00 | postgresql0 |
| 15 | 2365587616 | no recovery target specified | 2024-10-28T16:16:32.842442+09:00 | postgresql2 |
+----+------------+------------------------------+----------------------------------+-------------+

Query

You can run a database query against a PostgreSQL node with a specific role to see the results.

$ patronictl -c /etc/patroni/patroni.yml query -U postgres --password -c "SELECT VERSION();"
Password: 
version
PostgreSQL 14.13 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit

Failover

If there is no Leader node due to a failure in the cluster, you can manually run a failover.

$ patronictl -c /etc/patroni/patroni.yml failover

Current cluster topology
+ Cluster: opensql (7364637789542980847) ----------+----+-----------+------------------------+
| Member      | Host        | Role    | State     | TL | Lag in MB | Tags                   |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql0 | 192.1.1.218 | Replica | streaming | 20 |         0 |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql1 | 192.1.1.236 | Leader  | running   | 20 |           | failover_priority: 150 |
|             |             |         |           |    |           | nofailover: false      |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql2 | 192.1.1.238 | Replica | streaming | 20 |         0 |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
Candidate ['postgresql0', 'postgresql2'] []: postgresql2
Are you sure you want to failover cluster opensql, demoting current leader postgresql1? [y/N]: y
2024-11-04 16:36:12.20700 Successfully failed over to "postgresql2"
+ Cluster: opensql (7364637789542980847) --------+----+-----------+------------------------+
| Member      | Host        | Role    | State   | TL | Lag in MB | Tags                   |
+-------------+-------------+---------+---------+----+-----------+------------------------+
| postgresql0 | 192.1.1.218 | Replica | running | 20 |         0 |                        |
+-------------+-------------+---------+---------+----+-----------+------------------------+
| postgresql1 | 192.1.1.236 | Replica | stopped |    |   unknown | failover_priority: 150 |
|             |             |         |         |    |           | nofailover: false      |
+-------------+-------------+---------+---------+----+-----------+------------------------+
| postgresql2 | 192.1.1.238 | Leader  | running | 20 |           |                        |
+-------------+-------------+---------+---------+----+-----------+------------------------+

You can also perform a manual failover with the patronictl failover command in a healthy cluster. However, if you want to change the Leader instance in a healthy cluster, we recommend using the patronictl switchover command.

Switchover

This action converts the PostgreSQL/Patroni Leader node to a Replica and promotes one of the other Replica nodes to Leader.

$ patronictl -c /etc/patroni/patroni.yml switchover

Current cluster topology
+ Cluster: opensql (7364637789542980847) ----------+----+-----------+------------------------+
| Member      | Host        | Role    | State     | TL | Lag in MB | Tags                   |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql0 | 192.1.1.218 | Leader  | running   | 19 |           |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql1 | 192.1.1.236 | Replica | streaming | 19 |         0 | failover_priority: 150 |
|             |             |         |           |    |           | nofailover: false      |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql2 | 192.1.1.238 | Replica | streaming | 19 |         0 |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
Primary [postgresql0]: postgresql0
Candidate ['postgresql1', 'postgresql2'] []: postgresql1
When should the switchover take place (e.g. 2024-11-04T17:34 )  [now]: now
Are you sure you want to switchover cluster opensql, demoting current leader postgresql0? [y/N]: y
2024-11-04 16:35:07.34291 Successfully switched over to "postgresql1"
+ Cluster: opensql (7364637789542980847) --------+----+-----------+------------------------+
| Member      | Host        | Role    | State   | TL | Lag in MB | Tags                   |
+-------------+-------------+---------+---------+----+-----------+------------------------+
| postgresql0 | 192.1.1.218 | Replica | stopped |    |   unknown |                        |
+-------------+-------------+---------+---------+----+-----------+------------------------+
| postgresql1 | 192.1.1.236 | Leader  | running | 19 |           | failover_priority: 150 |
|             |             |         |         |    |           | nofailover: false      |
+-------------+-------------+---------+---------+----+-----------+------------------------+
| postgresql2 | 192.1.1.238 | Replica | running | 19 |         0 |                        |
+-------------+-------------+---------+---------+----+-----------+------------------------+

Pause / Resume

Stops the automatic failover feature of the Patroni cluster and puts the cluster into Maintenance Mode.

$ patronictl -c /etc/patroni/patroni.yml pause
Success: cluster management is paused

$ patronictl -c /etc/patroni/patroni.yml list
+ Cluster: opensql (7364637789542980847) ----------+----+-----------+------------------------+
| Member      | Host        | Role    | State     | TL | Lag in MB | Tags                   |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql0 | 192.1.1.218 | Replica | streaming | 25 |         0 |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql1 | 192.1.1.236 | Replica | streaming | 25 |         0 | failover_priority: 150 |
|             |             |         |           |    |           | nofailover: false      |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
| postgresql2 | 192.1.1.238 | Leader  | running   | 25 |           |                        |
+-------------+-------------+---------+-----------+----+-----------+------------------------+
 Maintenance mode: on

Exit maintenance mode with the Resume command and re-enable the automatic failover feature of the cluster.

$ patronictl -c /etc/patroni/patroni.yml resume
Success: cluster management is resumed

Check Configuration

You can view the DCS to see the configuration currently applied to your Patroni cluster.

$ patronictl -c /etc/patroni/patroni.yml show-config
loop_wait: 10
maximum_lag_on_failover: 1048576
postgresql:
  parameters:
    archive_command: barman-wal-archive node4 pg %p
    archive_mode: 'true'
    authentication_timeout: '200'
    log_line_prefix: '%m [%r] [%u] [%a]'
    max_connections: '250'
    wal_level: replica
    wal_receiver_timeout: '30000'
  pg_hba:
  - local all all trust
  - host replication patroni_repl 192.1.1.218/26 trust
  - host replication patroni_repl 127.0.0.1/32 trust
  - host all all 0.0.0.0/0 md5
  - host all barman 192.1.1.218/26 trust
  - host replication streaming_barman 192.1.1.218/26 trust
  use_pg_rewind: true
  use_slots: true
retry_timeout: 10
slots:
  barman:
    type: physical
ttl: 30

Modify Configuration

You can modify the Dynamic Configuration values of your Patroni cluster stored in DCS.

$ pctl edit-config

You can run a text editor or vi specified by the local user's EDITOR environment variable as a subprocess to modify and save the configuration in TTY format.

loop_wait: 10
maximum_lag_on_failover: 1048576
postgresql:
  parameters:
    archive_command: barman-wal-archive node4 pg %p
    archive_mode: 'false'
    authentication_timeout: '500'
    log_line_prefix: '%m [%r] [%u] [%a]'
    max_connections: 500
    wal_level: replica
    wal_receiver_timeout: '30000'
  pg_hba:
  - local all all trust
  - host replication patroni_repl 192.1.1.218/26 trust
  - host replication patroni_repl 127.0.0.1/32 trust
  - host all all 0.0.0.0/0 md5
  - host all barman 192.1.1.218/26 trust
  - host replication streaming_barman 192.1.1.218/26 trust
  use_pg_rewind: true
  use_slots: true
retry_timeout: 10
slots:
  barman:
    type: physical
ttl: 45
~
~
~
~
"/tmp/opensql-config-m332oce3.yaml" 25L, 683C

Last updated