heartbeat的安装和应用

下载三个包:http://www.linux-ha.org/wiki/Downloads

安装:Cluster-Resource-Agents-agents-1.0.3

#tar xxf Cluster-Resource-Agents-agents-1.0.3.tar.bz2 -C /usr/src
#cd Cluster-Resource-Agents-agents-1.0.3
#./autogen.sh
#./configure
#make
#make install

 

安装:Reusable-Cluster-Components-glue--glue-1.0.7   注意版本1.0.6很麻烦

 

#cd Reusable-Cluster-Components-glue--glue-1.0.7
#./autogen.sh
#./configure
#make
#make install


安装:Heartbeat-3-0-STABLE-3.0.4

#cd Heartbeat-3-0-STABLE-3.0.4
#./bootstrap
#./ConfigureMe configure
#make
#make install


-----------------------------------------------------------------------------------

编辑配置文件

# cp /usr/share/doc/ha.cf /etc/ha.d/

#cp /usr/share/doc/haresources /etc/ha.d/

#cp /usr/share/doc/authkeys /etc/ha.d/

# vim /etc/ha.d/ha.cf

debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility     local0
keepalive 2
deadtime 10
warntime 6
initdead 120                
udpport 694
ucast eth0 10.1.1.133
auto_failback on
node drbd01
node drbd02

 

# vim /etc/ha.d/authkeys

auth 1
1 crc

# chmod 600 /etc/ha.d/authkeys

 

heartbeat的配置文件有两个位置/etc/ha.d与/usr/etc/ha.d,将/usr/etc/ha.d中文件全部copy到/etc/ha.d中,删除/usr/etc/ha.d,然后使用命令ln -s /etc/ha.d /usr/etc/ha.d创建软连接


#cp /usr/etc/ha.d/* /etc/ha.d/
#ln -s /etc/ha.d /usr/etc/ha.d

 

#vim /etc/ha.d/haresources


haresources为以下内容


drbd01 IPaddr::10.2.2.2/32/eth0:0 httpd 
定义drdb01为主

10.2.2.2是 虚拟浮动ip httpd是判断是否成功的服务。httpd 可以换成自己定义脚本的。

# /etc/init.d/heartbeat start 

 

 

遇到的问题
libtool: Version mismatch error.  This is libtool 2.2.10, but the
libtool: definition of this LT_INIT comes from an older release.
libtool: You should recreate aclocal.m4 with macros from libtool 2.2.10
libtool: and run autoconf again.
gmake[1]: *** [NoSuchFunctionName.lo] Error 1
gmake[1]: Leaving directory `/usr/src/Reusable-Cluster-Components-glue--glue-1.0.7/replace'
make: *** [all-recursive] Error 1

这个问题的解决就是libtool版本不一致导致的,

可以将已安装的libtool覆盖到编译目录
cp /usr/local/bin/libtool .


 ha.cf
ucast eth0 10.1.1.133   这里是对方的ip 主要用于HA的相互检测 网络接口要注意了,我用的是专用接口,


参考一位网友的解释  下面本实验可以忽略
配置心跳的监控:haresources 
创建检测脚本(本处如果没有个监测脚本hearbeat 无法启动) 
vi /etc/init.d/test(内容如下) 
#!/bin/bash 
echo "" $>/dev/null 
chmod 777 /etc/init.d/test 
================================================ 
=========== 
#vi /etc/ha.d/haresources(配置资源文件) 
各主机这部分应完全相同。 
master.qiangao.com 192.168.10.200 test 
指定 master.qiangao.com 调用预先写好的一个测试脚本,系统附加一个虚拟IP 
192.168.10.200 给eth0:0 
这里如果master.qiangao.com 宕机后slave.qiangao.com 可以新分配IP 
192.168.10.200 

debugfile /var/log/ha-debug  #用于记录heartbeat的调试信息
logfile /var/log/ha-log           #用于记录heartbeat的日志信息
logfacility     local0            
keepalive 2                              #发送心跳报文的间隔,默认单位为秒,如果你毫秒为单位,那么需要在后面跟ms单位,如1500ms即代表1.5s 
deadtime 30                           #用于配置认为对方节点菪掉的间隔
initdead 30                             #如果节点的机器重启后,可能需要一些时间启动网络,这个时间与deadtime不一样,要单独对待
udpport 694                           #广播/单播通讯使用的udp端口 
mcast eth1 239.0.0.1 694 1 0 # 使用多播方式进行相互通信
auto_failback on                   #用于决定,当拥有该资源的属主恢复之后,资源是否变迁:是迁移到属主上,还是在当前节点上继续运行,直到当前节点出现故障。 
node space142                     #设置集群中的节点,注意:节点名必须与uname –n相匹配
node space143
compression     bz2              #当消息大于compression_threshold定义的大小时,使用bz2压缩消息
compression_threshold 2   #定义大于阈值为2k
crm respawn                       #启用Pacemaker cluster manager
# 以下两行是pacemaker-mgmt提供的hb_gui 连接所必须的,2.1.4时没有
apiauth         mgmtd   uid=root
respawn         root    /usr/lib64/heartbeat/mgmtd -v

 

 

 

 

 
 
  1. #vim /etc/ha.d/authkeys 

 

auth 1
1 sha1 0366577bdaed36f08b5f1c29431812dc

 

  该文件主要是用于集群中节点之间的认证,采用的算法和密钥(如果有的话)在集群中节点上必须相同,目前提供了3种算法:md5,sha1和crc。其中crc不能够提供认证,它只能够用于校验数据包是否损坏,而sha1,md5需要一个密钥来进行认证,从资源消耗的角度来讲,md5消耗的比较多,sha1次之,因此建议一般使用sha1算法。
注:该文件必须改为600权限

猜你喜欢

转载自huaonline.iteye.com/blog/1341468