免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4635 | 回复: 0

heartbeat2.1.4 实现监控应用服务(mysql)具体步骤 [复制链接]

论坛徽章:
0
发表于 2010-02-24 09:34 |显示全部楼层
heartbeat2.1.4 实现监控应用服务(mysql)具体步骤:
OS:centos 4.6
APP01:
eth0:10.1.2.111
eth1:100.100.100.100
APP02:
eth0:10.1.2.110
eth1:100.100.100.99
Vip:10.1.2.113
rpm -ivh heartbeat-pils-2.1.4-2.1.rpm
rpm -ivh heartbeat-stonith-2.1.4-2.1.rpm
rpm -ivh heartbeat-2.1.4-2.1.rpm
cat /etc/ha.d/ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility   local0
keepalive 1000ms
deadtime 10
warntime 5
initdead 60
udpport 694
bcast  eth1 eth0
auto_failback off
watchdog /dev/watchdog
crm on
node  APP02  APP01
ping 10.1.2.10
respawn root /usr/lib/heartbeat/ipfail
apiauth ipfail gid=root uid=root
EOD
cat /etc/ha.d/haresources
APP02 IPaddr::10.1.2.113/24/eth0 Mysql
EOD
#这里的Mysql是用来控制mysql的停止和启动和监控
echo -e "auth 1\n1 crc" >/etc/ha.d/authkeys
chmod 600 /etc/ha.d/authkeys
/usr/lib/heartbeat/haresources2cib.py
#在/var/lib/heartbeat/下会生成cib.xml文件,但该文件需要进行部分调整
只需修改cib.xml文件中资源部分:

     
      
      
        
      
      
        
         
         
         
        
      
      
      
      
        
      
      
     
   
修改为:

     
      
      
        
      
      
        
         
         
         
        
      
      
      
      
        
      
      
     
   
interval="30s"
timeout="15s"
即每30秒检测资源运行情况,如果发现资源不在,则尝试启动资源,如果15s后还未启动成功,则资源切换向另节点
注意:IPaddr使用的是ocf格式的控制脚本,路径为:/usr/lib/ocf/resource.d/heartbeat/IPaddr
   这里的Mysql没有指定使用什么风格的控制脚本,默认应该也是ocf,可在这里因为ocf下只有mysql,没有Mysql这个脚本
   heartbeat会去/etc/ha.d/resource.d/下寻找Mysql,在这里我使用了LSB风格,但使用很正常,这一点有些不解.
介绍一下ocf和lsb格式的区别:
LSB格式的脚本必须支持status功能,必须能接收start,stop,status,三个参数;而如果是OCF格式,则必须支持start,stop,monitor三个参数.其中status和monitor参数是用来监控资源的,非常重要.
例如LSB风格的脚本,运行./Mysql status时候,
返回值包含OK或则running则表示资源正常
返回值包含stopped或者No则表示资源不正常。
假如是OCF风格的脚本,运行./Mysql monitor时候,
返回0表示资源是正常的,
返回7表示资源出现问题.
ocf格式的启动脚本在/usr/lib/ocf/resource.d/heartbeat
lsb格式的启动脚本在/usr/lib/lsb/resource.d/heartbeat
cd /etc/ha.d/ && scp authkeys haresources ha.cf 10.1.2.110:/etc/ha.d/
cd /var/lib/heartbeat/crm
rm cib.xml.* -f
ssh 10.1.2.110 "rm /var/lib/heartbeat/crm/* -f"
scp cib.xml 10.1.2.110:/var/lib/heartbeat/crm/
note:heartbeat2.x不使用haresources,如果它的存在的话,在heartbeat启动时log中会出现一条WARN的信息:
heartbeat[30304]: 2008/11/26_20:02:02 WARN: File /etc/ha.d/haresources exists.
heartbeat[30304]: 2008/11/26_20:02:02 WARN: This file is not used because crm is enabled
但不影响使用.
启动heartbeat:
/etc/init.d/heartbeat start
#没有主次之分,谁先启动谁先获取资源.
监控资源运行情况:
#每3秒更新一次,显示当前资源的情况.
crm_mon -i3
#查看所有资源
[root@APP01 crm]# crm_resource -L
Resource Group: group_1
  IPaddr_10_1_2_113 (ocf::heartbeat:IPaddr)
  Mysql_2   (heartbeat:Mysql)
[root@APP01 crm]#
#查看资源跑在哪个节点上
[root@APP01 crm]# crm_resource -W -r Mysql_2
resource Mysql_2 is running on: APP01
[root@APP01 crm]#


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/111930/showart_2185652.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP