heartbeat 3的安装问题及其解决方法

我已经不是第一次介绍Heatbeat,通过yum可轻松安装Heartbeat 2.x,网上的资料(包括我以前的多篇日志)都已很详细的介绍了Heartbeat 2.x 的部署方式。而自2月Heartbeat 3.0.2,作为首个3.x Final Release 版本发布后,官方网站已改版,并建议从2.x更新到3.0.2,导致很多老的配置文档、说明等都很难找到链接。此外,触发我考虑使用Heartbeat 3,也正是前几天用Heartbeat 2.1.3+DRBD+Oracle配置时遇到大量的Bug,可见这里。虽然最终解决问题,但缺少官方的支持,今后的维护可能会遇到困难。为长远考虑,使用Heartbeat 3是势在必行的。
    幸亏,Heartbeat 3对比Heartbeat 2.x实际区别并不大,甚至可把Heartbeat 3理解为Heartbeat 2.x 按模块拆分后的版本,配置方式类同。所以,实际部署时,遇到的最大困难是安装问题。官方资料提供的都是源码,我不喜欢以源码方式来在生成系统上部署软件,这会给后续的维护带来很大的问题。通过努力,我终于成功编译一套heartbeat 3.0.3,带GUI管理方式的rpm。

一、关于Heartbeat 3
1、版本问题
Heartbeat 官方最后一个STABLE release 2.x 版本是2.1.4。
虽然Fedora、OpenSUSE 等项目曾提供2.99、3.0等rpm版本,但实际上版本都是基于Heartbeat 3.0和3.0.1源码编译的。目前网上大部分资料中介绍的Heartbeat 3使用的也是该版本。
Heartbeat 3 官方正式发布的首个版本是3.0.2,这也是为了区别上面提到的2.99。此外,由于3.0.2 的正式发布,原由OpenSUSE提供的下载地址,也已被删除。
更详细信息,请见:Announce: Final Release of Heartbeat 3.0.2, Cluster-Glue 1.0.2, and Resource-Agents 1.0.2
这些原理Heartbeat 3 与 2.x 基本是相同的,有疑问,可参考:[原]heartbeat 2.x基础架构

2、组成
Heartbeat 3与2.x 的最大差别在于,3 按模块把的原来2.x 拆分为多个子项目,并且提供了一个cluster-glue的组件,专用于Local Resource Manager 的管理。即heartbeat + cluster-glue + resouce-agent 三部分:

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


通过这三部分已可构成一套完整的HA集群系统。但是,这还不够,因为没有管理工具。
而原GUI 工具Cluster Resource Manager (简称CRM)也被拆分由另一独立项目Pacemaker 负责。Pacemaker 提供了多种用户接口:

引用
(1) crm shell 基于字符的管理方式;
(2)一个使用Ajax Web配置方式的 web konsole 窗口;
(3)hb_gui ,即 heartbeat gui 图形配置工具,这也是原来2.x的默认GUI 配置工具;
(4) DRBD-MC,一个基于Java的配置管理工具。


更详细介绍,请见:这里
以上几种用户管理接口,择其一即可。需要说明的是,Pacemaker 支持的Cluster Stacks中,除了Heartbeat,还支持OpenAIS。不过,OpenAIS 的内容已超出本文的范围,有待以后再做介绍。

二、关于rpm包
1、Heartbeat 3 的rpm
Heartbeat 3 官网上有提供Heartbeat 3.0.3、Cluster Glue 1.0.5、Resource Agents 1.0.3 的源码。下载回来编译安装即可。
若你像我一样,不喜欢用源码来部署生产系统,那你可以用源码包中的spec来编译。编译时,注意创建对应的源码包中的目录,spec中的变量设定等,但总体问题不大。
更好的是,在Pacemaker 的Install一文中,提供了EPEL 的安装包。若您的系统是Asianux 、RHEL、CentOS等,即可通过下面的方式来安装:

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm
wget -O /etc/yum.repos.d/pacemaker.repo http://clusterlabs.org/rpm/epel-5/clusterlabs.repo
yum install -y pacemaker corosync heartbeat


或者,直接点击下面的链接获取对应的rpm,或源码src.rpm:
http://www.clusterlabs.org/rpm/epel-5/
http://www.clusterlabs.org/rpm/epel-5/src/
通过以上安装过程,系统已提供搭建Heartbeat 3的环境,包括crm 命令行配置和管理工具(由pacemaker 提供)。但是,不包括hb_gui 图形配置工具。
※ 注意,我这里没有安装ldirectord,因为我没有用到LVS,若您需要监控LVS,可自行安装。

2、Pacemaker Python GUI
正如前文提到的,这是Pacemaker 提供的一个GUI 方式的配置管理工具,也就是heartbeat 2.x中的hb_gui 。
官方网站是:http://hg.clusterlabs.org/pacemaker/pygui
在某些Heartbeat 版本,例如Fedora 自行提供的2.99 中,称为:pacemaker-pygui-1.4,而目前最新版本是2.0,已改名为:pacemaker-mgmt-2.0.0 。
编译时,可能会遇到一些问题:
a、AC_PROG_INTLTOOL 报错
例如:

引用
# tar xvjf Pacemaker-Python-GUI-.tar.bz2 
# ./bootstrap 
Autoconf package autoconf found. 
......
./configure: line 2064: syntax error near unexpected token `0.35.2' 
./configure: line 2064: `AC_PROG_INTLTOOL(0.35.2)'


原因是,缺少一个依赖包intltool-0.35.0-2。安装后,运行:

# autoreconf -ifs
# ./bootstrap


请见:
Error on compiling Pacemaker-GUI 
[RPM] pacemaker-mgmt for corosync 1.1.2 and pacemaker 1.0.6 

b、delete_attr 错误
例如:

引用
.... 
mgmt_crm.c: In function 'on_cleanup_rsc': 
mgmt_crm.c:1307: warning: passing argument 9 of 'delete_attr' makes integer from pointer without a cast 
mgmt_crm.c:1307: error: too many arguments to function 'delete_attr' 
mgmt_crm.c:1316: warning: passing argument 9 of 'update_attr' makes integer from pointer without a cast 
mgmt_crm.c:1316: error: too many arguments to function 'update_attr' 
gmake[2]: *** [libhbmgmt_la-mgmt_crm.lo] Error 1 
gmake[2]: Leaving directory `/home/rc6/Pacemaker-Python-GUI-0f1490eaa8d8/mgmt/daemon' 
gmake[1]: *** [all-recursive] Error 1 
gmake[1]: Leaving directory `/home/rc6/Pacemaker-Python-GUI-0f1490eaa8d8/mgmt' 
make: *** [all-recursive] Error 1


该错误的原因是pacemaker 1.1中做了一些改变,而最新的pacemaker-mgmt 2.0也据此做了调整。但是,如果当前使用的pacemaker 还是1.0,那就会产生错误。

引用
# rpm -qa|grep pacemaker
pacemaker-libs-devel-1.0.9.1-1.AXS3
pacemaker-1.0.9.1-1.AXS3
pacemaker-libs-1.0.9.1-1.AXS3


解决方法是,参考这里,反向修改源码中的/mgmt/daemon/mgmt_crm.c 文件,以符合pacemaker 1.0 :

引用
     1.7 -    delete_attr(cib_conn, cib_sync_call, XML_CIB_TAG_STATUS, dest_node, NULL,
     1.8 +    delete_attr(cib_conn, cib_sync_call, XML_CIB_TAG_STATUS, dest_node, NULL, NULL,
......
    1.16 -        XML_CIB_TAG_CRMCONFIG, NULL, NULL, NULL, "last-lrm-refresh", now_s, FALSE);
    1.17 +        XML_CIB_TAG_CRMCONFIG, NULL, NULL, NULL, NULL, "last-lrm-refresh", now_s, FALSE);
    1.18    crm_free(now_s);


另一个方法是,使用老版本的pacemaker-mgmt 2.0.0包:点击下载
详细请见:
Erro compiling Pacemaker GUI client 

c、rpm 包
当然,最后我还是生成了几个rpm包:

引用
pacemaker-mgmt-2.0.0-1.1.x86_64.rpm
pacemaker-mgmt-client-2.0.0-1.1.x86_64.rpm
pacemaker-mgmt-devel-2.0.0-1.1.x86_64.rpm


可从附录中获得。

三、附录
说了这么多,我只是您希望明白Heartbeat 3 的构成,至于安装用的rpm,我已经为了准备好了:


该版本适用于红旗 Asianux 3.x、RHEL 5.x 、CentOS 5.x 的x86_64平台环境。
下载后,解压到某一目录,例如:/root/rpms,然后,在/etc/yum.repos.d中创建一个文件:

引用
cat heartbeat.repo
[heartbeat] 
name=Heartbeat 3 
baseurl=file:///root/rpms 
enabled=1


接着,先卸载旧的包:

# rpm -e `rpm -qa|grep heartbeat` 
# rpm -e `rpm -qa|grep openais`


最后,用下面的命令安装即可:

# yum install pacemaker corosync heartbeat ldirectord pacemaker-mgmt pacemaker-mgmt-client
以上转自:http://www.linuxfly.org/post/531/
作者已经介绍的很详细了,下边只是一些我遇到的问题:
会有一个Package pacemaker-mgmt-client-2.0.0-1.1.x86_64.rpm is not signed,忽略:
sudo yum  install pacemaker corosync heartbeat ldirectord pacemaker-mgmt pacemaker-mgmt-clientw --nogpgcheck
安装rpm时,你也许会遇到各种问题,反正我是折腾了很久才搞定的。看有哪些包缺失,按照响应版本装吧:
Error: Missing Dependency: librdmacm.so.1()(64bit) is needed by package corosynclib-1.2.5-1.3.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: librdmacm.so.1(RDMACM_1.0)(64bit) is needed by package corosynclib-1.2.5-1.3.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: libltdl.so.3()(64bit) is needed by package heartbeat-3.0.3-1.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: libltdl.so.3()(64bit) is needed by package cluster-glue-libs-1.0.5-1.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: net-snmp is needed by package pacemaker-mgmt-2.0.0-1.1.x86_64 (heartbeat)
Error: Missing Dependency: perl-Net-SSLeay is needed by package ldirectord-1.0.3-1.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: libltdl.so.3()(64bit) is needed by package heartbeat-libs-3.0.3-1.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: libibverbs.so.1(IBVERBS_1.0)(64bit) is needed by package corosynclib-1.2.5-1.3.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: libltdl.so.3()(64bit) is needed by package cluster-glue-1.0.5-1.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: net-snmp is needed by package pacemaker-1.0.9.1-1.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: libltdl.so.3()(64bit) is needed by package pacemaker-mgmt-2.0.0-1.1.x86_64 (heartbeat)
Error: Missing Dependency: libltdl.so.3()(64bit) is needed by package pacemaker-libs-1.0.9.1-1.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: libltdl.so.3()(64bit) is needed by package pacemaker-1.0.9.1-1.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: perl(Socket6) is needed by package ldirectord-1.0.3-1.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: libopenhpi.so.2()(64bit) is needed by package cluster-glue-1.0.5-1.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: ipvsadm is needed by package ldirectord-1.0.3-1.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: libibverbs.so.1()(64bit) is needed by package corosynclib-1.2.5-1.3.AXS3.x86_64 (heartbeat)
Error: Missing Dependency: libibverbs.so.1(IBVERBS_1.1)(64bit) is needed by package corosynclib-1.2.5-1.3.AXS3.x86_64 (heartbeat)
如果没有继续装吧,期间还会涉及到perl的一系列包,最好有个安装盘在手边,不然你就得到处下载。。。。
深呼吸,此处建议你休息一会,装这些东西很是让人纠结。。。
sudo yum  install pacemaker corosync heartbeat ldirectord pacemaker-mgmt pacemaker-mgmt-clientw --nogpgcheck
如果有missing就一直去装,直到:
Total                                                                                                                                334 MB/s | 3.1 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : libhbaapi                                       [ 1/16] 
  Installing     : libesmtp                                        [ 2/16] 
  Installing     : libnet                                          [ 3/16] 
  Installing     : perl-TimeDate                                   [ 4/16] 
  Installing     : perl-MailTools                                  [ 5/16] 
  Installing     : ldirectord                                      [ 6/16] 
  Installing     : cluster-glue-libs                               [ 7/16] 
  Installing     : cluster-glue                                    [ 8/16] 
  Installing     : corosynclib                                     [ 9/16] 
  Installing     : resource-agents                                 [10/16] 
  Installing     : corosync                                        [11/16] 
  Installing     : heartbeat-libs                                  [12/16] 
  Installing     : pacemaker-libs                                  [13/16] 
  Installing     : pacemaker                                       [14/16] 
  Installing     : heartbeat                                       [15/16] 
  Installing     : pacemaker-mgmt                                  [16/16] 
Installed: corosync.x86_64 0:1.2.5-1.3.AXS3 heartbeat.x86_64 0:3.0.3-1.AXS3 ldirectord.x86_64 0:1.0.3-1.AXS3 pacemaker.x86_64 0:1.0.9.1-1.AXS3 pacemaker-mgmt.x86_64 0:2.0.0-1.1
Dependency Installed: cluster-glue.x86_64 0:1.0.5-1.AXS3 cluster-glue-libs.x86_64 0:1.0.5-1.AXS3 corosynclib.x86_64 0:1.2.5-1.3.AXS3 heartbeat-libs.x86_64 0:3.0.3-1.AXS3 libesmtp.x86_64 0:1.0.4-5.AXS3 libhbaapi.x86_64 0:2.2-4AXS3 libnet.x86_64 0:1.1.2.1-5AXS3 pacemaker-libs.x86_64 0:1.0.9.1-1.AXS3 perl-MailTools.noarch 0:1.77-1.AXS3 perl-TimeDate.noarch 1:1.16-5.AXS3 resource-agents.x86_64 0:1.0.3-1.AXS3
Complete!

 

另外heartbeat需要samba作为共享协议比如共享硬盘等设备,rpm -qa | grep samba看你装了哪些:

 

 

samba-common-3.0.33-3.28.el5

samba-client-3.0.33-3.28.el5

samba-3.0.33-3.28.el5

 

 

装好samba后,启动吧:sudo /etc/rc.d/init.d/smb start

 

关于samba的安装,可以参考:http://developer.51cto.com/art/200512/12825.htm

 

 

特别注意的是由于共享ip,需要设置:echo 1 >/proc/sys/net/ipv4/ip_nonlocal_bind

 

 

     

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

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

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

    抵扣说明:

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

    余额充值