由于某种原因,MySQL经常停止运行。
我想学习如何创build一个脚本来检查MySQL是否closures,如果是这样, 那么使用service mysql start重新启动它。
有什么build议么?
安装并使用monit
你可以监视mysql进程,如果它是closures的,可以重新启动它..一个示例configuration可能看起来像
check process mysql with pidfile /var/run/mysqld/mysqld.pid group database start program = "service mysql start" stop program = "service mysql stop" if failed host 127.0.0.1 port 3306 protocol mysql then restart if 5 restarts within 5 cycles then timeout