os: centos 7.4
postgresql: 9.6.9
etcd: 3.2.18
patroni: 1.4.4
本篇blog介绍下 etcd + patroni 发生切换时使用 callback 来重新设定 master 的 vip。
主要是方便自有机房或托管的,云环境貌似不能绑定固定的vip。
patroni 的一些参数
https://patroni.readthedocs.io/en/latest/SETTINGS.html
官方文档描述在callback时又这几个状态:
on_reload: run this script when configuration reload is triggered.
on_restart: run this script when the cluster restarts.
on_role_change: run this script when the cluster is being promoted or demoted.
on_start: run this script when the cluster starts.
on_stop: run this script when the cluster stops.
# su - postgres
$ vi /usr/patroni/conf/patroni_postgresql.yml
postgresql:
callbacks:
on_start: /usr/patroni/conf/patroni_callback.s