Sobes.tech
Junior — Middle

Have you participated in setting up and managing a PostgreSQL cluster using Patroni?

sobes.tech AI

Answer from AI

Patroni is a tool for managing highly available PostgreSQL clusters with automatic failover. It uses a distributed configuration store (such as Etcd, Consul, or ZooKeeper) for coordination.

If you have been involved in setting up and managing a PostgreSQL cluster with Patroni, you likely performed the following tasks:

  • Installed and configured Patroni on multiple servers.
  • Configured cluster parameters, including replication and failover.
  • Set up a distributed store for coordination (Etcd, Consul).
  • Tested automatic failover of the primary node in case of failures.
  • Monitored the cluster status and troubleshot issues.

Example Patroni configuration (yaml):

scope: postgres_cluster
namespace: /service/
name: node1

restapi:
  listen: 0.0.0.0:8008
  connect_address: 192.168.1.1:8008

etcd:
  host: 127.0.0.1:2379

bootstrap:
  dcs:
    ttl: 30
    loop_wait: 10
    retry_timeout: 10
    maximum_lag_on_failover: 1048576
  initdb:
  - encoding: UTF8
  - data-checksums

postgresql:
  listen: 0.0.0.0:5432
  connect_address: 192.168.1.1:5432
  data_dir: /var/lib/postgresql/data
  parameters:
    max_connections: 100
    shared_buffers: 256MB
    wal_level: replica
    hot_standby: "on"

If you lack experience, it is recommended to study the Patroni documentation and try deploying a test cluster.