专注,勤学,慎思。戒骄戒躁,谦虚谨慎

just do it

导航

pg_auto_failover集群monitor节点的高可用


pg_auto_failover一直被诟病为monitor节点为单点模式,昨天想了个办法,解决monitor节点单点的问题,一个正常的pg_auto_failover集群(不管是几个数据节点),用流复制手动做一个monitor节点的standby节点,如下图,如果需要切换,只需要修改所有数据节点的配置文件中的monitor配置的uri,然后手动pg_promote standby节点,发现这样是可以直接用standby接替原始monitor节点的工作的。
 
 

image

1,原始的monitor节点以及keeper数据节点

image

image

 

2,创建monitor节点的流复制standby节点pafmonitor-new节点,细节略

 

3,修改pg_auto_failover的配置文件/pg_autoctl.cfg中的monitor配置项为新的monitor节点,所有数据节点都修改,修改完成后在新的monitor节点上select pg_promote()提升为可读写

image

 pg_autoctl show file

image

 

4,pg_autoctl show uri查看新的monitor

此时pg_autoctl show uri已经变为新的节点,keeper数据节点状态正常,

image

 特意重启主节点,尝试了一次自动故障转移,完美

image

 

 

最后:官方推荐的是通过pg_autoctl disable monitor --force,然后重新pg_autoctl enable monitor 来指定一个新的monitor节点,这种方式来实现monitor的“容灾”,并没有提到这种修改配置文件的方式来实现monitor节点的容灾,经过自己尝试后这种方式是可以实现monitor节点的容灾的。

 

posted on 2026-03-20 10:53  MSSQL123  阅读(5)  评论(0)    收藏  举报