Heartbeat是著名HA项目,Heartbeat在3.0之后分拆为Heartbeat和Pacemaker 两个各自独立项目。Pacemaker在后续发展中使用Corosync作为消息层,和Corosync紧密结合,同时也保留Heartbeat作为可选的消息层。所以新版Pacemaker 1.1.x 和heartbeat3.x 结合方面有些问题,安装复杂,特此记录下安装过程中的问题及解决办法,以供借鉴。
安装环境:
Redhat Enterprise linux 6.4
CentOS 6.5
安装路径:/usr/local/heartbeat
软件:
Cluster Glue 1.0.9 (中间层,粘合heartbeat和pacemaker,提供LRM和STONITH等工具及类库)
Resource Agents 3.9.2(提供各类资源脚本以供调用)
Heartbeat 3.0.5 (消息层,负责消息传递)
注:Heartbeat 2.1.4之后原先的项目被拆分成Cluster Glue,Resource Agents,Heartbeat 3个子项目
下载:http://www.linux-ha.org/wiki/Downloads
Pacemaker 1.1.11(即Cluster Resource Manager,简称CRM,用来管理整个HA的控制中心,属于管理层,客户端通过pacemaker来配置管理监控整个集群)
注:从pacemaker 1.1.8开始,crmsh(https://savannah.nongnu.org/projects/crmsh/)发展成一个独立项目,pacemaker中不再提供,我们安装好pacemaker后,没有crm这个命令行模式的资源管理器。Redhat发行版提供了另一个命令行管理器pcs作为crmsh替代, pcs还提供图形界面但需另外安装。
Pacemaker内部结构
准备工作:
1.yum install或rpm -ivh安装以下依赖软件包,以免安装过程中出错
autoconf automake libtool glib2-devel libxml2-devel bzip2-devel e2fsprogs-devel libxslt-devel libtool-ltdl-devel
2.添加用户和组
新建用户hacluster属于新建组haclient,用于配置respawn,软件安装中均指定uid=hacluster,gid=haclient
# groupadd haclient
# useradd -g haclient hacluster -M -s /sbin/nologin
安装过程,须按顺序
1.安装Cluster Glue
# tar jxvf glue-1.0.9.tar.bz2 # cd Reusable-Cluster-Components-glue--glue-1.0.9/
# ./autogen.sh
# ./configure --prefix=/usr/local/heartbeat --with-daemon-user=hacluster --with-daemon-group=haclient --sysconfdir=/etc/heartbeat libdir=/usr/local/heartbeat/lib64 LIBS=‘/lib64/libuuid.so.1‘
# make && make install
注:在./configure的时候指定一下LIBS=‘/lib64/libuuid.so.1‘,同理Resource Agents,Heartbeat,Pacemaker 在./configure的时候都指定一下,不然继续报错。
./.libs/libplumb.so: undefined reference to `uuid_parse’
./.libs/libplumb.so: undefined reference to `uuid_generate’
./.libs/libplumb.so: undefined reference to `uuid_copy’
./.libs/libplumb.so: undefined reference to `uuid_is_null’
./.libs/libplumb.so: undefined reference to `uuid_unparse’
./.libs/libplumb.so: undefined reference to `uuid_clear’
./.libs/libplumb.so: undefined reference to `uuid_compare’
...........................................................
configure: error: You do not have the libuuid development package installed
2.安装Resource Agents
# cd ClusterLabs-resource-agents-b735277/ # ./autogen.sh # ./configure --prefix=/usr/local/heartbeat --sysconfdir=/etc/heartbeat libdir=/usr/local/heartbeat/lib64 CFLAGS=-I/usr/local/heartbeat/include LDFLAGS=-L/usr/local/heartbeat/lib64 LIBS=‘/lib64/libuuid.so.1‘ # make && make install # ln -s /usr/local/heartbeat/lib64/* /lib64/
注:建立一个软连接,避免编译时找不到所需要的包. 如缺少一些依赖包,会有错误提示,按照提示安装相应包即可。
安装glue, resource agent, heartbeat时,需要到网上下载docbook-style-xsl, docbook-dtds包,如网速慢容易出现以下错误,可单独下载或用yum安装docbook-style-xsl, docbook-dtds包,以提高安装速度。
无法下载docbook时会发生类似错误:
error : Operation in progress
warning: failed to load external entity "http://docbook.sourceforge.net/release/xsl/current/html/formal.xsl"
compilation error: file http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl line 46 element include
xsl:include : unable to load http://docbook.sourceforge.net/release/xsl/current/html/formal.xsl
http://docbook.sourceforge.net/release/xsl/current/html/table.xsl:1: parser error : Document is empty
http://docbook.sourceforge.net/release/xsl/current/html/table.xsl:1: parser error : Start tag expected, ‘<‘ not found
compilation error: file http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl line 47 element include
xsl:include : unable to load http://docbook.sourceforge.net/release/xsl/current/html/table.xsl
3.安装Heartbeat
# cd Heartbeat-3-0-7e3a82377fa8/ # ./bootstrap # ./configure --prefix=/usr/local/heartbeat --with-daemon-user=hacluster --with-daemon-group=haclient --sysconfdir=/etc/heartbeat CFLAGS=-I/usr/local/heartbeat/include LDFLAGS=-L/usr/local/heartbeat/lib64 LIBS=‘/lib64/libuuid.so.1‘ # make && make install
make报错:
In file included from ../include/lha_internal.h:41,
from strlcpy.c:1:
/usr/local/heartbeat/include/heartbeat/glue_config.h:105:1: error: "HA_HBCONF_DIR" redefined
In file included from ../include/lha_internal.h:38,
from strlcpy.c:1:
../include/config.h:390:1: error: this is the location of the previous definition
gmake[1]: *** [strlcpy.lo] Error 1
解决办法:
编辑/usr/local/heartbeat/include/heartbeat/glue_config.h的第50行和最后1行(105行)
将 #define HA_SYSCONFDIR "/etc/heartbeat" 注释掉 ,避免路径重复定义错误。
将 #define HA_HBCONF_DIR "/etc/heartbeat/ha.d/" 注释掉 ,避免路径重复定义错误。
4.Pacemaker安装
Pacemaker默认使用Corosync,yum和rpm安装Pacemaker均是使用Corosync,因此下载源码包进行安装。
https://github.com/ClusterLabs/pacemaker/
# cd pacemaker-master-1.1.11/ # ./autogen.sh # ./configure --prefix=/usr/local/heartbeat --with-daemon-user=hacluster --with-daemon-group=haclient libdir=/usr/local/heartbeat/lib64 CFLAGS=-I/usr/local/heartbeat/include LDFLAGS=-L/usr/local/heartbeat/lib64 LIBS=‘/lib64/libuuid.so.1‘ --with-heartbeat # make && make install
configure: error: Version of libqb is too old: v0.13 or greater requried
解决方法:安装libqb-devel和libqb
rpm -ivh libqb-devel-****.rpm和libqb-****.rpm
No package ‘dbus-1‘ found
解决方法:安装dbus-devel
rpm -ivh dbus-devel-****.rpm
checking for native corosync... try
checking for cpg... configure: error: Package requirements (libcpg) were not met:
No package ‘libcpg‘ found
解决方法:安装corosynclib-devel
yum -y install corosynclib-devel
或rpm -ivh corosynclib-devel-*.rpm
注:corosync,corosynclib,corosynclib-devel相互间存在依赖关系,3个软件包的版本必须相同
make出现错误:
gmake[2]: Entering directory `/tools/pacemaker-master/lib/common‘
CC ipc.lo
CC utils.lo
cc1: warnings being treated as errors
utils.c: In function ‘crm_generate_uuid’:
utils.c:2515: error: implicit declaration of function ‘uuid_generate’
utils.c:2515: error: nested extern declaration of ‘uuid_generate’
utils.c:2516: error: implicit declaration of function ‘uuid_unparse’
utils.c:2516: error: nested extern declaration of ‘uuid_unparse’
gmake[2]: *** [utils.lo] Error 1
解决方法:安装libuuid-devel
rpm -ivh libuuid-devel-*.rpm
然后重新执行./configure,再重新make
安装完成后,链接一些必要库文件,以免运行时出错
ln -s /usr/local/heartbeat/usr/lib/ocf/* /usr/lib/ocf
ln -s /usr/local/heartbeat/libexec/pacemaker /usr/libexec
ln -s /usr/local/heartbeat/share/pacemaker /usr/share
ln -s /usr/local/heartbeat/var/lib/pacemaker /var/lib
ln -s /usr/local/heartbeat/lib64/pkgconfig/*.* /usr/lib64/pkgconfig/
ln -s /usr/local/heartbeat/lib64/python2.6/site-packages/* /usr/lib64/python2.6/site-packages/
至此4个软件都已安装成功,下节介绍Heartbeat+Pacemaker+Apache+MySQL 设置和测试
本文出自 “东尼乐园” 博客,请务必保留此出处http://ittony.blog.51cto.com/6242212/1541670
Heartbeat 3.x+Pacemaker 1.1.x 安装教程1,布布扣,bubuko.com
Heartbeat 3.x+Pacemaker 1.1.x 安装教程1
原文:http://ittony.blog.51cto.com/6242212/1541670