概述
Patroni
+ etcd
+ vipmanager
是cybertec推出的postgresql 高可用方案。其中, Etcd 用于存放集群状态信息。Patroni 负责为PostgreSQL 集群提供故障转移和高可用服务。vipmanager 根据etcd或Consul中保存的状态管理虚拟IP用于提供和管理虚拟ip,用于对外提供访问地址。
部署
vip-manager Github 文档,可以直接下载RPM包进行安装。
下载
wget https://github.com/cybertec-postgresql/vip-manager/releases/download/v2.5.0/vip-manager_2.5.0_Linux_x86_64.rpm
- 安装
rpm -ivh vip-manager_2.5.0_Linux_x86_64.rpm
rpm -qa
查询所有RPM包;rpm -e
卸载 RPM 包
- 修改默认配置:
/etc/default/vip-manager.yml
# 检测间隔,单位毫秒
interval: 1000
# 和 patroni 配置保持一致:<namespace>/<scope>/leader
trigger-key: "/service/pg/leader"
# 和 patroni 配置保持一致:<name>
trigger-value: "data7"
ip: 172.16.20.99 # 虚拟ip
netmask: 24 # netmask for the virtual ip
interface: ens192 #网卡
# how the virtual ip should be managed. we currently support "ip addr add/remove" through shell commands or the Hetzner api
hosting-type: basic # possible values: basic, or hetzner.
dcs-type: etcd # etcd or consul
# etcd 地址
dcs-endpoints:
- http://172.16.20.152:2379
- http://172.16.20.153:2379
- http://172.16.20.154:2379
# 本地的认证都取消了,没有配置
#etcd-user: "patroni"
#etcd-password: "Julian's secret password"
# when etcd-ca-file is specified, TLS connections to the etcd endpoints will be used.
#etcd-ca-file: "/path/to/etcd/trusted/ca/file"
# when etcd-cert-file and etcd-key-file are specified, we will authenticate at the etcd endpoints using this certificate and key.
#etcd-cert-file: "/path/to/etcd/client/cert/file"
#etcd-key-file: "/path/to/etcd/client/key/file"
# don't worry about parameter with a prefix that doesn't match the endpoint_type. You can write anything there, I won't even look at it.
#consul-token: "Julian's secret token"
# how often things should be retried and how long to wait between retries. (currently only affects arpClient)
retry-num: 2
retry-after: 250 #in milliseconds
# verbose logs (currently only supported for hetzner)
verbose: false
- 启动/停止/自启
systemctl start vip-manager
systemctl stop vip-manager
systemctl enable vip-manager