heartbeat3.0安装和配置

来源:互联网 发布:新华网数据新闻 编辑:程序博客网 时间:2024/05/16 09:26

heartbeat简介

heartbeat 项目是 Linux-HA 工程的一个组成部分,它实现了一个高可用集群系统。例如,节点间的内部通信方式、集群合作管理机制、监控工具和失效切换功能等。但是heartbeat仅仅是个HA软件,它仅能完成心跳监控和资源接管,不会监视它控制的资源或应用程序。要检测资源和应用程序是否正常,必须通过第三方插件实现,例如:ipfail、Mon和Ldirector等。

heartbeat3.0组成

heartbeat3.0版本有三部分组成:Heartbeat、Cluster Glue、Resource Agents

1、hearbeat本身是整个集群的基础(cluster messaging layer),负责维护集群各节点的信息以及它们之前通信;
2、cluster-glue相当于一个中间层,可以将heartbeat和crm(pacemaker)联系起来,主要包含2个部分,LRM和STONITH;
3、resource-agent,就是各种的资源的ocf脚本,这些脚本将被LRM调用从而实现各种资源启动、停止、监控等等。

 heartbeat3.0安装

下面介绍两种安装方法:源码安装和rpm包安装
1、源码安装

a、安装Reusable-Cluster-Components-glue--glue-1.0.7

  1. #groupadd haclient 
  2. #useradd -g haclient hacluster 
  3. #wget http://hg.linux-ha.org/glue/archive/glue-1.0.7.tar.bz2 
  4. #tar jxvf glue-1.0.7.tar.bz2 
  5. #cd Reusable-Cluster-Components-glue--glue-1.0.7/ 
  6. #./autogen.sh 
  7. #./configure 
  8. #make 
  9. #make install 

b、安装 Cluster-Resource-Agents-agents-1.0.3

  1. #wget https://download.github.com/ClusterLabs-resource-agents-agents-1.0.4-0-gc06b6f3.tar.gz 
  2. #tar -jvxf ClusterLabs-resource-agents-agents-1.0.4-0-gc06b6f3.tar.gz 
  3. #cd Cluster-Resource-Agents-agents-1.0.4 
  4. #./autogen.sh 
  5. #./configure 
  6. #make 
  7. #make install 

c、安装 Heartbeat-3-0-STABLE-3.0.4.tar.bz2

  1. #wget http://hg.linux-ha.org/heartbeat-STABLE_3_0/archive/STABLE-3.0.4.tar.bz2 
  2. #tar jxvf STABLE-3.0.4.tar.bz2 
  3. #cd Heartbeat-3-0-STABLE-3.0.4/ 
  4. #./bootstrap 
  5. #./ConfigureMe configure 
  6. #make 
  7. #make install 

 注:在使用源码安装时候在线校验一些xml文件,会耗费大量的时间。我整个安装用了2个小时以上。

2、rpm包安装

下载相关的rpm包,并采用本地yum源方式安装。具体请参考该文:http://www.linuxfly.org/post/531/

heartbeat3.0配置

1、配置ha.cf

  1. vim /etc/ha.d/ha.cf  

debugfile /var/log/ha-debug  #用于记录heartbeat的调试信息
logfile /var/log/ha-log           #用于记录heartbeat的日志信息
logfacility     local0            
keepalive 2                              #发送心跳报文的间隔,默认单位为秒,如果你毫秒为单位,那么需要在后面跟ms单位,如1500ms即代表1.5s 
deadtime 30                           #用于配置认为对方节点菪掉的间隔
initdead 30                             #网络启动的时间
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

2、配置authkeys

  1. #vim /etc/ha.d/authkeys 
auth 1
1 sha1 0366577bdaed36f08b5f1c29431812dc

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

 

heartbeat启动和资源管理
1、启动heartbeat

  1. #service heartbeat start 

2、集群资源管理

集群资源管理工具有以下几种:pacemaker提供crm shell 工具,而pacemaker-mgmt和pacemaker-mgmt-client则提供了hb_gui 图形工具,还有基于Ajax web方式的管理工具。关于pacemaker相关资料可参考:http://www.clusterlabs.org/doc/zh-CN/Pacemaker/1.1/pdf/Clusters_from_Scratch/Pacemaker-1.1-Clusters_from_Scratch-zh-CN.pdf 

 

本文出自 “木子” 博客,请务必保留此出处http://junlee.blog.51cto.com/228061/530686

原创粉丝点击