主库维护重启操作
1、备库停掉keepalived
#root执行 [root@standby1 sbin]# kill -9 `cat /var/run/keepalived.pid` [root@standby1 sbin]# ps aux | grep keepalived root 19675 0.0 0.0 112808 968 pts/1 R+ 01:51 0:00 grep --color=auto keepalived
2、主库重启,需要在lightdb用户下执行
[lightdb@master ~]$ ltcluster -f $PGHOME/etc/ltcluster/ltcluster.conf service pause NOTICE: node 1 (lightdbCluster102030105432) paused NOTICE: node 2 (lightdbCluster102030115432) paused
3、查看集群状态,确认primary的Paused?状态为yes
[lightdb@master ~]$ ltcluster -f $PGHOME/etc/ltcluster/ltcluster.conf service status
4、主库停止数据库实例
[lightdb@master ~]$ lt_ctl -D $PGDATA stop waiting for server to shut down........ # 如果有连接存在导致stop failed,则可以尝试使用 lt_ctl -D $PGDATA stop -m smart # 如果仍然stop failed,且因条件限制无法或不希望断开所有客户端连接,则可以使用-m immediate强制停止数据 库,此方式下没有回滚连接,即强制断开、强制停止,没有完全shutdown,会导致在启动时recovery lt_ctl -D $PGDATA stop -m immediate
5、修改数据库参数
略...
6、重新启动主库
lt_ctl -D $PGDATA start
7、恢复主库ltclusterd状态
ltcluster -f $PGHOME/etc/ltcluster/ltcluster.conf service unpause NOTICE: node 2 (lightdbCluster102030115432) unpaused
8、查看集群状态
[lightdb@master pg_wal]$ ltcluster -f $PGHOME/etc/ltcluster/ltcluster.conf service status ID | Name | Role | Status | Upstream | ltclusterd | PID | Paused? | Upstream last seen ----+----------------------------+---------+-----------+----------------------------+------------+-------+---------+-------------------- 1 | lightdbCluster102030105432 | primary | * running | | running | 4819 | no | n/a 2 | lightdbCluster102030115432 | standby | running | lightdbCluster102030105432 | running | 31133 | no | 0 second(s) ago