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"。如果仅在启用后查看回溯信息,可以将其设置为
DEBUG
。PATRONI_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_NUM
和PATRONI_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=strongpasswd
和PATRONI_admin_OPTIONS='createrole,createdb'
将导致使用密码strongpasswd
创建用户admin
,该密码可用于创建其他用户和数据库。