{"id":24215,"library":"patroni","title":"Patroni","description":"Patroni is a Python-based orchestrator for managing high-availability PostgreSQL clusters using Distributed Configuration Stores (DCS) like etcd, Consul, ZooKeeper, or Kubernetes. Current version is 4.1.2. It follows a rapid release cadence with frequent minor and patch releases.","status":"active","version":"4.1.2","language":"python","source_language":"en","source_url":"https://github.com/patroni/patroni","tags":["postgresql","high-availability","orchestrator","database","etcd","consul","zookeeper","raft"],"install":[{"cmd":"pip install patroni","lang":"bash","label":"Install Patroni with default dependencies (etcd, consul, zookeeper, raft)."}],"dependencies":[{"reason":"Required for PostgreSQL connectivity.","package":"psycopg2-binary","optional":false},{"reason":"etcd DCS support (optional if using other DCS).","package":"python-etcd","optional":true},{"reason":"Consul DCS support (optional).","package":"python-consul","optional":true},{"reason":"ZooKeeper DCS support (optional).","package":"kazoo","optional":true},{"reason":"RAFT consensus (optional, for standalone).","package":"pysyncobj","optional":true}],"imports":[{"wrong":"from patroni import Patroni","symbol":"Patroni","correct":"import patroni"}],"quickstart":{"code":"from patroni import Patroni\n\nconfig = {\n    'namespace': '/service/',\n    'scope': 'batman',\n    'name': 'postgresql0',\n    'restapi': {'listen': '0.0.0.0:8008', 'connect_address': '127.0.0.1:8008'},\n    'etcd': {'host': '127.0.0.1:2379'},\n    'bootstrap': {\n        'dcs': {'ttl': 30, 'loop_wait': 10, 'retry_timeout': 10, 'maximum_lag_on_failover': 1048576},\n        'initdb': [{'encoding': 'UTF8'}, {'data-checksums': 'true'}],\n        'pg_hba': ['host replication replicator 127.0.0.1/32 md5', 'host all all 0.0.0.0/0 md5'],\n        'users': {'admin': {'password': 'admin', 'options': ['createrole', 'createdb']}}\n    },\n    'postgresql': {\n        'listen': '0.0.0.0:5432',\n        'connect_address': '127.0.0.1:5432',\n        'data_dir': 'data/postgresql0',\n        'bin_dir': '/usr/lib/postgresql/14/bin',\n        'pgpass': '/tmp/pgpass',\n        'authentication': {'replication': {'username': 'replicator', 'password': 'rep-pass'},\n                           'superuser': {'username': 'postgres', 'password': 'secret-password'}},\n        'parameters': {'unix_socket_directories': '.'}\n    },\n    'tags': {'nofailover': False, 'noloadbalance': False}\n}\n\npatroni = Patroni(config)\npatroni.run()","lang":"python","description":"Minimal Patroni instance using etcd as DCS. Adjust listen addresses, credentials, and PostgreSQL paths."},"warnings":[{"fix":"Upgrade Python to 3.8 or higher.","message":"Patroni v4.x drops support for Python 3.6/3.7. Requires Python 3.8+.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Ensure 'name' in config is unique per node (e.g., postgresql0, postgresql1).","message":"Running multiple Patroni instances with identical config name can cause split-brain. Each node must have a unique 'name'.","severity":"gotcha","affected_versions":"all"},{"fix":"Use 'etcd' key instead of 'etcd2'. Refer to docs for the new format.","message":"Old DCS configuration keys like 'etcd2' and 'consul' changed to 'etcd' and 'consul' with different structure in v3.0+. 'etcd2' is removed in v4.x.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Update systemd unit to include Restart=always or use the template from the official repository.","message":"Systemd unit files shipped with earlier versions may not restart Patroni automatically on failure. In v4.x, the recommended unit is 'patroni.service' with Restart=always.","severity":"gotcha","affected_versions":"<4.0.0"},{"fix":"Set 'postgresql.bin_dir' to the directory containing PostgreSQL binaries (e.g., /usr/lib/postgresql/14/bin).","message":"Configuration option 'postgresql.bin_dir' is now required in v4.x if psql is not on PATH.","severity":"breaking","affected_versions":">=4.0.0"}],"env_vars":null,"search_vec":"'4.1.2':30 'avail':13,46 'base':7 'cadenc':36 'cluster':15 'configur':18 'consul':23,50 'current':27 'databas':48 'dcs':20 'distribut':17 'etcd':22,49 'follow':32 'frequent':38 'high':12,45 'high-avail':11,44 'kubernet':26 'like':21 'manag':10 'minor':39 'orchestr':8,47 'patch':41 'patroni':1,2 'postgresql':14,43 'python':6 'python-bas':5 'raft':52 'rapid':34 'releas':35,42 'store':19 'use':16 'version':28 'zookeep':24,51","created_at":"2026-05-01T08:11:54.166911+00:00","updated_at":"2026-05-01T08:11:54.166911+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"4.1.3","cli_name":"patroni","cli_version":"FATAL: Patroni requires psycopg2>=2.5.4, psycopg2-binary, or psycopg>=3.0.0","type":"library","homepage":"https://patroni.readthedocs.io","github":"https://github.com/patroni/patroni","docs":null,"changelog":null,"pypi":"https://pypi.org/project/patroni/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","devops","aws","gcp","azure"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-08-02","install_tag":null}}