Patroni 修改配置
Patroni 修改配置
背景
- 使用 Patroni 部署 postgresql 集群的时候,不能单独修改单点的配置,这里需要通过 Patroni 来修改配置。
修改步骤
1. 修改 postgres 集群的 max_connections 参数。
[root@postgres0 ~]# patronictl -c /etc/patroni.yml edit-config postgres loop_wait: 10 maximum_lag_on_failover: 1048576 postgresql: parameters: # 注意:添加参数的时候,max_connections: 500 中间的冒号紧跟着一个**空格**,然后才是属性值。 max_connections: 500 use_pg_rewind: true retry_timeout: 10 ttl: 30 --- +++ @@ -1,6 +1,8 @@ loop_wait: 10 maximum_lag_on_failover: 1048576 postgresql: + parameters: + max_connections: 500 use_pg_rewind: true retry_timeout: 10 ttl: 30 # 这里输入 y ,应用所有更改。 Apply these changes? [y/N]:
1. 查看集群状态,最后一列状态栏 Pending restart 里面都是 * 号,表示配置已经修改,需要重启生效。
[root@loanapi ~]# patronictl -c /etc/patroni.yml list +----------+--------+---------------+--------+---------+----+-----------+-----------------+ | Cluster | Member | Host | Role | State | TL | Lag in MB | Pending restart | +----------+--------+---------------+--------+---------+----+-----------+-----------------+ | postgres | pg01 | 172.26.114.87 | | running | 4 | 0.0 | * | | postgres | pg02 | 172.26.114.88 | | running | 4 | 0.0 | * | | postgres | pg03 | 172.26.114.90 | Leader | running | 4 | 0.0 | * | +----------+--------+---------------+--------+---------+----+-----------+-----------------+
1. 重启所有节点,使配置生效(重启一个再查看状态,就会发现 Pending restart 的星号没有了)。
[root@loanapi ~]# patronictl -c /etc/patroni.yml restart postgres pg01 When should the restart take place (e.g. 2019-09-11T10:49) [now]: +----------+--------+---------------+--------+---------+----+-----------+-----------------+ | Cluster | Member | Host | Role | State | TL | Lag in MB | Pending restart | +----------+--------+---------------+--------+---------+----+-----------+-----------------+ | postgres | pg01 | 172.26.114.87 | | running | 4 | 0.0 | * | | postgres | pg02 | 172.26.114.88 | | running | 4 | 0.0 | * | | postgres | pg03 | 172.26.114.90 | Leader | running | 4 | 0.0 | * | +----------+--------+---------------+--------+---------+----+-----------+-----------------+ Are you sure you want to restart members pg01? [y/N]: y Restart if the PostgreSQL version is less than provided (e.g. 9.5.2) []: Success: restart on member pg01
补充信息
通过日志查看修改的内容是否正常。
# 如果你修改错了,页面上没有提示。 Sep 9 16:20:02 postgres0 patroni: 2019-09-09 16:20:02,337 INFO: Lock owner: pg01; I am pg01 Sep 9 16:20:02 postgres0 patroni: 2019-09-09 16:20:02,353 INFO: no action. i am the leader with the lock Sep 9 16:20:02 postgres0 patroni: 2019-09-09 16:20:02,356 INFO: No PostgreSQL configuration items changed, nothing to reload. # 如果你修改的对了,就会提示如下信息。 Sep 9 16:44:40 postgres0 patroni: 2019-09-09 16:44:40,046 INFO: no action. i am the leader with the lock Sep 9 16:44:40 postgres0 patroni: 2019-09-09 16:44:40,081 INFO: Changed max_connections from 100 to 101 (restart required) Sep 9 16:44:50 postgres0 patroni: 2019-09-09 16:44:50,027 INFO: Lock owner: pg01; I am pg01 Sep 9 16:44:50 postgres0 patroni: 2019-09-09 16:44:50,039 INFO: no action. i am the leader with the lock
本文来自博客园,作者:duchaoqun,转载请注明原文链接:https://www.cnblogs.com/duchaoqun/p/12060404.html
分类:
PostgreSQL
标签:
Postgresql
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?