1、重新编译内核,加入watchdog
Device Drivers ->
Character Devices ->
Watchdog Cards -> [*] Watchdog Timer Support [ ] Disable watchdogshutdown on close
--- Watchdog DeviceDrivers
<*> Your Watchdog card orchip
2、安装watchdog程序
apt-get install watchdog
3、配置watchdog
可以参考的文档包括:
http://gentoo-wiki.com/HOWTO_Watchdog_Timer
man 8 watchdog
man 5 watchdog.conf
/usr/share/doc/watchdog/examples
我只是用它来保障sshd、apache和mysql运行稳定。
4、确保apache、ssh和mysql在watchdog之前起来
重起机器后,watchdog会查找这三个进程的pid,如果不存在,默认会重起机器(除非我们设置了repair binary),因此,一定要在启动脚本中改变启动顺序,让watchdog在这三者启动之后才启用。
5、设置repair脚本
我并不想这几个应用程序随便出点啥事就重启计算机,所以,写了个简单的脚本:
root@wlj:/var/run# cat /usr/sbin/repair.sh
#!/bin/sh
if [ -x /etc/init.d/networking ]; then
# Debian /etc/init.d/networking restartelif [ -x /etc/rc.d/init.d/network ]; then