Heartbeat中Watchdog的使用

内核有它自己的方法处理挂起的系统,叫做watchdogwatchdog只是一 个内核模块,它检查计时器确定系统是健康的,如果watchdog认为内核挂起,它可能做出激烈的响应,如重启系统,如果你想保护你的高可用服务器配置, 服务器挂起时导致服务中断,Heartbeat也检测不到,你应该在你的内核中启用watchdog

注意:这里我们讨论的是服务器挂起而不是应用程序问题,Heartbeat(在编写本书时Heartbeat 2之前的版本还不可用)不会监视它控制的资源或应用程序,看其是否健康 -- 要监视必须使用另一个软件包,如Mon,将在第四部分中详细讨论它。

正常情况下,连接到系统的watchdog设备允许内核判断系统是否挂起(当内核看不到外部的计时器设备正确地更新时,它就知道出现某些错误了)。

watchdog代码也支持用软件替换外部的硬件计时器,该软件叫做 softdog,softdog维护一个内部计时器,在另一个进程写入/dev/watchdog设备文件时更新,如果softdog没有看到进程写入 /dev/watchdog文件,它认为内核一定出故障了,它将启动一个内核恐慌,正常情况下,内核恐慌将导致系统关闭,但是你可以修改这个默认行为,将 其改为默认行为为重启系统。

当你在/etc/ha.d/ha.cf文件中启用了watchdog选项 后,Heartbeat将每隔相当于deadtime长的时间写入/dev/watchdog文件(或设备),因此,出现任何导致Heartbeat更新 watchdog设备失败的事情,一旦watchdog超时周期(默认是一分钟)过期,watchdog将启动内核恐慌。

配置信息如下:

[root@Server ~]# yum install watchdog*
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package watchdog.i386 0:5.6-1.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================
 Package                          Arch                         Version                          Repository                    Size
====================================================================================================================================
Installing:
 watchdog                         i386                         5.6-1.el5                        base                          66 k

Transaction Summary
====================================================================================================================================
Install      1 Package(s)        
Update       0 Package(s)        
Remove       0 Package(s)        

Total download size: 66 k
Is this ok [y/N]: y
Downloading Packages:
watchdog-5.6-1.el5.i386.rpm                                                                                  |  66 kB     00:00    
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : watchdog                                                                                                     1/1

Installed:
  watchdog.i386 0:5.6-1.el5           

2.开启看门狗选项

[root@Server ~]# vi /etc/ha.d/ha.cf

watchdog /dev/watchdog  取消开头的# 注释

[root@Server ~]# lsmod
Module                  Size  Used by
softdog                 9941  2

3.测试(模拟heartbeat突然崩溃)

[root@Server ~]# ps -ef|grep heartbeat
root      6384     1  0 15:04 ?        00:00:00 heartbeat: master control process
nobody    6387  6384  0 15:04 ?        00:00:00 heartbeat: FIFO reader     
nobody    6388  6384  0 15:04 ?        00:00:00 heartbeat: write: ucast eth0
nobody    6389  6384  0 15:04 ?        00:00:00 heartbeat: read: ucast eth0
nobody    6390  6384  0 15:04 ?        00:00:00 heartbeat: write: ucast eth1
nobody    6391  6384  0 15:04 ?        00:00:00 heartbeat: read: ucast eth1
nobody    6392  6384  0 15:04 ?        00:00:00 heartbeat: write: ping 172.18.4.50
nobody    6393  6384  0 15:04 ?        00:00:00 heartbeat: read: ping 172.18.4.50
root      6420  5515  0 15:06 pts/1    00:00:00 grep heartbeat


[root@Server ~]# Killall -9 heartbeat

[root@Server ~]# ps -ef|grep heartbeat
root      6430  5515  0 15:09 pts/1    00:00:00 grep heartbeat

4.观察日志:

[root@Server ~]# tail -f /var/log/message

Aug  2 15:09:39 Server kernel: SoftDog: Unexpected close, not stopping watchdog!

我们发现 系统已经重启了。。。


参考文章:
http://www.ixdba.net/article/97/2036.html (HeartbeatWatchdog和Softdog的使用)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值