检查PostgreSQL服务器状态的HTTP服务器
pgstatus的Python项目详细描述
用于检查PostgreSQL服务器状态的HTTP守护程序
此存储库实现了一个永久的http守护进程来监视postgresql数据库状态 并决定配置中的哪个服务器是活动主机。
haproxy使用来自工具的响应将通信量重定向到可写postgres主服务器和只读从服务器 服务器并检测不可用的Postgres服务器。
配置文件
配置路径是~/.config/pgstatus.conf。如果要监视 不是本地主机的postgres服务器:5432作为用户postgres,不使用postgres作为数据库进行检查。
请参阅examples目录中的示例配置文件。
请参见examples/haproxy.conf中的haproxy示例配置。
运行服务
examples/pgstatus-daemon.service中提供了示例systemd服务单元,默认配置为 以postgres用户身份运行(因此通常不需要为默认postgres配置用户和密码)。
要安装:
cp examples/pgstatus-daemon.service /etc/systemd/system/ systemctl daemon-reload systemctl enable pgstatus-daemon systemctl start pgstatus-daemon
学分
基本思路是基于网站
https://severalnines.com/blog/postgresql-load-balancing-using-haproxy-keepalived
代替XeNETD和Shell脚本,它实现了作为系统控制的检查。 永久守护进程。