Monit 在运行 pg_dump 期间对 PostgreSQL 的“是否活动”检查往往会失败,有没有更好的方法?

Monit 在运行 pg_dump 期间对 PostgreSQL 的“是否活动”检查往往会失败,有没有更好的方法?

我使用 pg_dump 进行主备份,每三个小时一次。我还使用 monit。当 monit 在 pg_dump 运行期间检查 PostgreSQL 是否处于活动状态时,它有时会超时并重新启动 postgres。这会导致备份失败。

该怎么办?转到预写日志?备份期间禁用 monit?数据库此时正在为活跃的网站提供服务。

监控配置:

check process postgres with pidfile /usr/local/pgsql/data/postmaster.pid
group database
start program = "/etc/init.d/postgresql start"
stop program = "/etc/init.d/postgresql stop"
if failed unixsocket /tmp/.s.PGSQL.5432 protocol pgsql then restart
if failed host 127.0.0.1 port 5432      protocol pgsql then restart
if 5 restarts within 5 cycles then timeout

答案1

所以是这样的吗?

if failed unixsocket /tmp/.s.PGSQL.5432 protocol pgsql for 5 cycles then restart
if failed host 127.0.0.1 port 5432      protocol pgsql for 5 cycles then restart
if 5 restarts within 25 cycles then timeout

这样,在重新启动之前,monit 检查必须 15 分钟内无法访问。假设循环间隔为 180 秒。显然,您可以根据自己的喜好进行调整,但如果您的服务器恰好很忙或被占用,则在一次检查失败后重置可能会导致误报。

相关内容