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は変更を全メンバーに適用し、リロード可能なものは直ちに有効化し、再起動が必要なものは'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はプライマリより低くできないため、再起動の順序をそれに応じて計画する。