我使用pg_dump进行主备份,每三个小时一次。 我也用monit。 当monit在pg_dump运行期间检查PostgreSQL是否存在时,它有时会超时,并重新启动postgres。 这会导致备份失败。
该怎么办? 移动到预先写日志? 在备份期间禁用监视? 数据库在这些时间正在服务于一个活跃的网站。
监控configuration:
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
所以这样的事情?
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秒的周期间隔。 很明显,您可以根据自己的口味进行调整,但是如果您的服务器正忙或者被占用,一次失败的检查可能会导致误报。