日期:2014-05-16  浏览次数:20982 次

Linux高可用性方案之Heartbeat日志查看(原创)

日志是我们跟踪系统和应用程序最好的方式,在Heartbeat中日志可以自定义输出位置,只需在ha.cf文件配置即可,具体可参见笔者的
http://czmmiao.iteye.com/blog/1174010

下面跟着笔者我们来看详细看下Heartbeat的日志
启动主机Heartbeat服务

#/etc/init.d/heartbeat start
Heartbeat启动时,通过"tail -f /var/log/ messages"查看主节点系统日志信息,输出如下:
# tail -f /var/log/messages?
??? Nov 26 07:52:21 node1 heartbeat: [3688]: info:
??? Configuration validated. Starting heartbeat 2.0.8?
??? Nov 26 07:52:21 node1 heartbeat: [3689]: info:
??? heartbeat: version 2.0.8?
??? Nov 26 07:52:21 node1 heartbeat: [3689]: info:
??? Heartbeat generation: 3?
??? Nov 26 07:52:21 node1 heartbeat: [3689]: info:
??? G_main_add_TriggerHandler: Added signal manual handler?
??? Nov 26 07:52:21 node1 heartbeat: [3689]: info:
??? G_main_add_TriggerHandler: Added signal manual handler?
??? Nov 26 07:52:21 node1 heartbeat: [3689]: info:
??? glib: UDP Broadcast heartbeat started on port 694 (694) interface eth1?
??? Nov 26 07:52:21 node1 heartbeat: [3689]: info:
??? glib: UDP Broadcast heartbeat closed on port 694 interface eth1 - Status: 1?
??? Nov 26 07:52:21 node1 heartbeat: [3689]: info:
??? glib: ping heartbeat started.?
??? Nov 26 07:52:21 node1 heartbeat: [3689]: info:
??? G_main_add_SignalHandler: Added signal handler for signal 17?
??? Nov 26 07:52:21 node1 heartbeat: [3689]: info:
??? Local status now set to: 'up'?
??? Nov 26 07:52:22 node1 heartbeat: [3689]: info:
??? Link node1:eth1 up.?
??? Nov 26 07:52:23 node1 heartbeat: [3689]: info:
??? Link 192.168.60.1:192.168.60.1 up.?
??? Nov 26 07:52:23 node1 heartbeat: [3689]: info:
??? Status update for node 192.168.60.1: status ping

此段日志是Heartbeat在进行初始化配置,例如,Heartbeat的心跳时间间隔、UDP广播端口和ping节点的运行状态等,日志信息到这里会暂停,等待120秒之后,Heartbeat会继续输出日志,而这个120秒刚好是ha.cf中"initdead"选项的设定时间。此时Heartbeat的输出信息如下:
??? Nov 26 07:54:22 node1 heartbeat: [3689]: WARN: node node2: is dead?
??? Nov 26 07:54:22 node1 heartbeat: [3689]: info:
??? Comm_now_up(): updating status to active?
??? Nov 26 07:54:22 node1 heartbeat: [3689]: info:
??? Local status now set to: 'active'?
??? Nov 26 07:54:22 node1 heartbeat: [3689]: info:
??? Starting child client "/usr/lib/heartbeat/ipfail" (694,694)?
??? Nov 26 07:54:22 node1 heartbeat: [3689]: WARN:
??? No STONITH device configured.?

??? Nov 26 07:54:22 node1 heartbeat: [3689]: WARN:
??? Shared disks are not protected.?
??? Nov 26 07:54:22 node1 heartbeat: [3689]: info:
??? Resources being acquired from node2.?
??? Nov 26 07:54:22 node1 heartbeat: [3712]: info:
??? Starting "/usr/lib/heartbeat/ipfail" as uid 694? gid 694 (pid 3712)

在上面这段日志中,由于node2还没有启动,因此会给出"node2: is dead"的警告信息,接下来启动了Heartbeat插件ipfail。由于我们在ha.cf文件中没有配置STONITH,因此日志里也给出了"No STONITH device configured"的警告提示。
继续看下面的日志:
??? Nov 26 07:54:23 node1 harc[3713]: info: Running /etc/ha.d/rc.d/status status?
??? Nov 26 07:54:23 node1 mach_down[3735]: info: /usr/lib/
??? heartbeat/mach_down: nice_failback: foreign resources acquired?
??? Nov 26 07:54:23 node1 mach_down[3735]: info: mach_down
??? takeover complete for node node2.?
??? Nov 26 07:54:23 node1 heartbeat: [3689]: info: mach_down takeover complete.?
??? Nov 26 07:54:23 node1 heartbeat: [3689]: info: Initial
??? resource acquisition complete (mach_down)?
??? Nov 26 07:54:24 node1 IPaddr[3768]: INFO:? R