4.patroni手册—Environment Configuration Settings

Patroni是一个用于管理和高可用性部署PostgreSQL的工具,它允许通过环境变量覆盖配置文件设置。本文档详细列出了所有可设置的环境变量,包括全局配置、日志、引导程序配置、Consul、Ecd、Zookeeper、Exhibitor、Kubernetes、PostgreSQL、REST API和CTL的相关选项。例如,PATRONI_LOG_LEVEL用于设置日志级别,PATRONI_LOG_DIR指定日志写入目录,而PATRONI_POSTGRESQL_LISTEN用于配置PostgreSQL监听的地址。了解这些环境变量有助于精细控制Patroni的行为和优化PostgreSQL集群的管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Environment Configuration Settings

可以使用系统环境变量覆盖patroni配置文件中定义的某些配置参数。本文档列出了patroni处理的所有环境变量。通过这些变量设置的值始终优先于patroni配置文件中设定的值。

全局/通用

  • PATRONI_CONFIGURATION:可以通过PATRONI_CONFIGURATION环境变量设置Patroni的整个配置。在这种情况下,将不考虑任何其他环境变量!
  • PATRONI_MAME:正在运行的patroni实例节点名称。在整个集群中必须是唯一的
  • PATRONI_NAMESPACE:patroni将在路径下保留有关集群的配置信息。默认配置为"/service"
  • PATRONI_SCOPE:集群名称

日志

  • PATRONI_LOG_LEVEL: 设置常规日志记录级别,默认是"INFO"(详情参见:the docs for Python logging)
  • PATRONI_LOG_TRACEBACK_LEVEL:设置显示日志回溯的级别,默认值是"ERROR"。如果仅在启用后查看回溯信息,可以将其设置为DEBUGPATRONI_LOG_LEVEL=DEBUG
  • PATRONI_LOG_FORMAT:设置日志格式文本串,默认值为%(asctime)s %(levelname)s: %(message)s。(详情参见the LogRecord attributes
  • PATRONI_LOG_DATEFORMAT:设置时间格式。(详见formatTime() documentation
  • PATRONI_LOG_MAX_QUEUE_SIZE:patroni使用两步日志记录的方式。日志被写入内存队列中,并且有一个单独的现成将其从队列中拉出并写入到stderr或文件中。默认情况下,内部队列的最大大小受到1000条记录的限制,足以保留过去1h20min的日志记录。
  • PATRONI_LOG_DIR:应用日志的写入目录。这个目录必须存在并且patroni的执行用户必须对此用户有可写权限。如果设置此env变量,则默认情况下该应用程序将保留4个25MB的日志。您可以使用PATRONI_LOG_FILE_NUMPATRONI_LOG_FILE_SIZE来调整这些保留值。
  • PATRONI_LOG_FILE_NUMBER:应用日志的保留数量
  • PATRONI_LOG_FILE_SIZE:触发patroni.log文件轮转的文件大小(bytes)
  • PATRONI_LOG_LOGGERS:重新定义每个python模块的日志记录级别。 例PATRONI_LOG_LOGGERS="{patroni.postmaster: WARNING, urllib3: DEBUG}"

引导程序配置

在成功初始化新集群之后,可以立即创建新的数据库用户。此过程由以下变量定义:

  • Most of the parameters are optional, but you have to specify one of the host, hosts, url, proxy or srv

    host: the host:port for the etcd endpoint.
    hosts: list of etcd endpoint in format host1:port1,host2:port2,etc… Could be a comma separated string or an actual yaml list.
    use_proxies: If this parameter is set to true, Patroni will consider hosts as a list of proxies and will not perform a topology discovery of etcd cluster.
    url: url for the etcd.
    proxy: proxy url for the etcd. If you are connecting to the etcd using proxy, use this parameter instead of url.
    srv: Domain to search the SRV record(s) for cluster autodiscovery.
    protocol: (optional) http or https, if not specified http is used. If the url or proxy is specified - will take protocol from them.
    username: (optional) username for etcd authentication.
    password: (optional) password for etcd authentication.
    cacert: (optional) The ca certificate. If present it will enable validation.
    cert: (optional) file with the client certificate.
    key: (optional) file with the client key. Can be empty if the key is part of cert.PATRONI__PASSWORD=’’

  • PATRONI__OPTIONS=‘list,of,options’

示例:定义PATRONI_admin_PASSWORD=strongpasswdPATRONI_admin_OPTIONS='createrole,createdb'将导致使用密码strongpasswd创建用户admin,该密码可用于创建其他用户和数据库。

Consul

    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值