• 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
    
  • 相关阅读:
    oracle函数大全(转载)
    oracle的基本数据类型(转载)
    oracle 数据类型详解---日期型(转载)
    队列的链式存储结构
    在Lua里写unity游戏笔记
    NGUI-快捷键
    NGUI在线电子书---NGUI for Unity
    NGUI学习笔记-UISprite
    unity延时方法Invoke和InvokeRepeating
    NGUI-制作位图字体以及图文混排
  • 原文地址:https://www.cnblogs.com/duchaoqun/p/12060404.html
Copyright © 2020-2023  润新知