在 Patroni 中修改集群范围参数(edit-config)并应用待处理的重启
PostgreSQLPatroni命令
# Show the current dynamic configuration stored in the DCS:
patronictl -c /etc/patroni/patroni.yml show-config <cluster>
# Cluster-wide PostgreSQL parameter (distributed to all members):
patronictl -c /etc/patroni/patroni.yml edit-config <cluster> -p 'work_mem=64MB' -p 'max_connections=500' --force
# Patroni behavior parameter:
patronictl -c /etc/patroni/patroni.yml edit-config <cluster> -s 'maximum_lag_on_failover=1048576' --force
# Parameters requiring a restart are flagged as 'Pending restart':
patronictl -c /etc/patroni/patroni.yml list <cluster> -e
# Restart replicas first, then the leader:
patronictl -c /etc/patroni/patroni.yml restart <cluster> --role replica --pending --force
patronictl -c /etc/patroni/patroni.yml restart <cluster> --role leader --pending --force作用
将 PostgreSQL 和 Patroni 参数写入 DCS 中的动态配置;Patroni 将变更应用到所有成员,立即激活可 reload 的参数,并将需要重启的参数标记为 'Pending restart'。
适用场景
用于在 Patroni 管理的集群的每个节点上一致地修改 max_connections、shared_buffers 或 work_mem 等参数。
注意
在 Patroni 下,不要手动编辑 postgresql.conf 或使用 ALTER SYSTEM:Patroni 会重写 postgresql.conf,而 postgresql.auto.conf 会覆盖 Patroni 的设置,导致节点之间出现配置漂移。备库上的 max_connections、max_worker_processes、max_wal_senders、max_prepared_transactions 和 max_locks_per_transaction 不能低于主库;请据此规划重启顺序。