HA

Centos6.4安装heartbeat3.0详解

#此文档其实可以当成脚本,只要把软件下载到相应的目录即可 在这里软件是放在/soft
#此实验软件下载地址:http://pan.baidu.com/share/link?shareid=600042051&uk=823269712
#环境说明:
#系统: Centos6.4 系统采用基本安装
node1(主服务器):eth0:192.168.1.6(node1)eth1:10.0.9.103(priv1)
node2(从服务器):eth0:192.168.1.8(node2)eth1:10.0.9.121(priv2)
VIP地址:192.168.1.100
#新建用户
groupadd haclient
useradd -g haclient hacluster
#定义变量
cat << EOF >> /root/.bash_profile
export PREFIX=/usr/local/ha
export LCRSODIR=$PREFIX/libexec/lcrso
export CLUSTER_USER=hacluster
export CLUSTER_GROUP=haclient
export CFLAGS="$CFLAGS -I$PREFIX/include -L$PREFIX/lib"
getent group ${CLUSTER_GROUP} >/dev/null || groupadd -r ${CLUSTER_GROUP}
getent passwd ${CLUSTER_USER} >/dev/null || useradd -r -g ${CLUSTER_GROUP} -d /var/lib/heartbeat/cores/hacluster -s /sbin/nologin -c "cluster user" ${CLUSTER_USER}
EOF
#安装前,yum安装缺的包
yum install -y glib2-devel bzip2-devel libxml2 libxml2-devel libtool-ltdl-devel buuid-devel automake autoconf docbook-style-xsl libxslt-devel gettext libaio-devel resource-agents
#安装各个模块软件包
#安装Cluster Glue
#这个放软件的目录 /soft
cd /soft
tar zxf Reusable-Cluster-Components-glue--02bdcf58f9a0.tar.gz
cd Reusable-Cluster-Components-glue--02bdcf58f9a0
./autogen.sh
./configure --prefix=$PREFIX --with-daemon-user=${CLUSTER_USER} --with-daemon-group=${CLUSTER_GROUP} --enable-fatal-warnings=no LIBS=/lib/libuuid.so.1
#注意:如果你是64位系统将LIBS=/lib64/libuuid.so.1 强烈建议安装下面3个软件业要指定一下,不然也会报错
make && make install
#安装Resource Agents
cd /soft
tar zxf resource-agents-3.9.5.tar.gz
cd resource-agents-3.9.5
./autogen.sh
./configure --prefix=$PREFIX --enable-fatal-warnings=no LIBS=/lib/libuuid.so.1
make && make install
#安装heartbeat
cd /soft
tar zxf Heartbeat-3-0-545554f6fc0a.tar.gz
cd Heartbeat-3-0-545554f6fc0a
./bootstrap
./configure --prefix=$PREFIX --enable-fatal-warnings=no
make && make install
#安装pacemaker
cd /soft
tar jxf Pacemaker-1-0-c3869c00c759.tar.bz2
cd Pacemaker-1-0-c3869c00c759
./autogen.sh
./configure --prefix=$PREFIX --with-lcrso-dir=$LCRSODIR --enable-fatal-warnings=no LIBS=/lib/libuuid.so.1
make && make install
##########################[size=16]#报错信息[/size]######################[size=16]#[/size]
You must have autoconf installed to compile the cluster-glue package.
Download the appropriate package for your system,
or get the source tarball at: ftp://ftp.gnu.org/pub/gnu/autoconf/
解决方法:
 yum install automake
Download the appropriate package for your system,
or get the source tarball at: ftp://ftp.gnu.org/pub/gnu/automake/
解决方法:
yum install autoconf
You must have libtool installed to compile the cluster-glue package.
Download the appropriate package for your system,
or get the source tarball at: ftp://ftp.gnu.org/pub/gnu/libtool/
解决方法:
yum install  libtool
./configure时出现configure: error: BZ2 libraries not found
解决办法:yum -y install bzip2-devel glib2-devel
make的时候
安装Reusable-Cluster-Components-glue--glue-1.0.9
 ./.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’
 collect2: ld returned 1 exit status
 gmake[2]: *** [ipctest] Error 1
 gmake[2]: Leaving directory `/root/Reusable-Cluster-Components-glue-1.0.6/lib/clplumbing’
 gmake[1]: *** [all-recursive] Error 1
 gmake[1]: Leaving directory `/root/Reusable-Cluster-Components-glue-1.0.6/lib’
 make: *** [all-recursive] Error 1
 解决办法:
 ./configure --prefix=$PREFIX --with-daemon-user=${CLUSTER_USER} --with-daemon-group=${CLUSTER_GROUP} --enable-fatal-warnings=no LIBS='/lib64/libuuid.so.1'
 各位在./configure的时候指定一下LIBS,如果是32位系统的话改成LIBS='/lib/libuuid.so.1'。下面ClusterLabs-resource Heartbeat在./configure的时候都指定一下,要不然继续报错。
解决办法:yum install e2fsprogs-devel libuuid-devel
make的时候报错
/usr/bin/xsltproc \
--xinclude \
http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl hb_report.xml
error : Operation in progress
warning: failed to load external entity "http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
cannot parse http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
gmake[2]: *** [hb_report.8] Error 4
gmake[2]: Leaving directory `/heartbeat/Reusable-Cluster-Components-glue--5e06b2ddd24b/doc'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/heartbeat/Reusable-Cluster-Components-glue--5e06b2ddd24b/doc'
make: *** [all-recursive] Error 1
解决方法:
yum -y install docbook-style-xsl
查看日志发现错误
grep -i error /var/log/ha-log
Sep 14 19:33:38 node1 pengine: [29617]: ERROR: unpack_resources: Resource start-up disabled since no STONITH resources have been defined
Sep 14 19:33:38 node1 pengine: [29617]: ERROR: unpack_resources: Either configure some or disable STONITH with the stonith-enabled option
Sep 14 19:33:38 node1 pengine: [29617]: ERROR: unpack_resources: NOTE: Clusters with shared data need STONITH to ensure data integrity
Sep 14 19:33:45 node1 pengine: [29617]: info: process_pe_message: Configuration ERRORs found during PE processing. Please run "crm_verify -L" to identify issues.
解决方法:STONITH默认是开启的,而我们做实验的时候是没有这个设备,所以要关闭它
STONTIH设备详解请参考:http://czmmiao.iteye.com/blog/1174667
关闭方法是:
[root@localhost ~]# /usr/local/ha/sbin/crm
abort: couldn't find crm libraries in [/usr/local/ha/sbin /usr/lib/python26.zip /usr/lib/python2.6 /usr/lib/python2.6/plat-linux2 /usr/lib/python2.6/lib-tk /usr/lib/python2.6/lib-old /usr/lib/python2.6/lib-dynload /usr/lib/python2.6/site-packages /usr/lib/python2.6/site-packages/gtk-2.0 /usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info]
(check your install and PYTHONPATH)
解决方法:
vim .bash_profile
然后添加以下内容
export PYTHONHONME=/usr/local/ha
export PYTHONPATH=$PYTHONHOME:/usr/local/ha/lib/python2.6/site-packages
export PATH=$PATH:/usr/local/ha/sbin
最后执行 source .bash_profile
[root@node1 ~]# vim /etc/hosts  添加以下内容
192.168.1.6       node1
192.168.1.8       node2
10.0.9.103        priv1
10.0.9.121        priv2
拷贝配置文件
[root@node1 ~]# cp /usr/local/ha/share/doc/heartbeat/ha.cf  /usr/local/ha/etc/ha.d/
[root@node1 ~]# cp /usr/local/ha/share/doc/heartbeat/haresources  /usr/local/ha/etc/ha.d
[root@node1 ~]# cp /usr/local/ha/share/doc/heartbeat/authkeys  /usr/local/ha/etc/ha.d/
ha.cf配置文件部分参数详解:
logfile /var/log/ha-log
#指名heartbaet的日志存放位置
keepalive 2
#指定心跳使用间隔时间为2秒(即每两秒钟在eth1上发送一次广播)
deadtime 30
#指定备用节点在30秒内没有收到主节点的心跳信号后,则立即接管主节点的服务资源
warntime 10
#指定心跳延迟的时间为十秒。当10秒钟内备份节点不能接收到主节点的心跳信号时,就会往日志中写入一个警告日志,但此时不会切换服务
initdead 120
#在某些系统上,系统启动或重启之后需要经过一段时间网络才能正常工作,该选项用于解决这种情况产生的时间间隔。取值至少为deadtime的两倍。
    
udpport 694
#设置广播通信使用的端口,694为默认使用的端口号。
baud    19200
#设置串行通信的波特率
       
bcast   eth0        # Linux  指明心跳使用以太网广播方式,并且是在eth0接口上进行广播。
#mcast eth0 225.0.0.1 694 1 0
#采用网卡eth0的Udp多播来组织心跳,一般在备用节点不止一台时使用。Bcast、ucast和mcast分别代表广播、单播和多播,是组织心跳的三种方式,任选其一即可。
#ucast eth0 192.168.1.2
#采用网卡eth0的udp单播来组织心跳,后面跟的IP地址应为双机对方的IP地址
auto_failback on
#用来定义当主节点恢复后,是否将服务自动切回,heartbeat的两台主机分别为主节点和备份节点。主节点在正常情况下占用资源并运行所有的服务,遇到故障时把资源交给备份节点并由备份节点运行服务。在该选项设为on的情况下,一旦主节点恢复运行,则自动获取资源并取代备份节点,如果该选项设置为off,那么当主节点恢复后,将变为备份节点,而原来的备份节点成为主节点
#stonith baytech /etc/ha.d/conf/stonith.baytech
# stonith的主要作用是使出现问题的节点从集群环境中脱离,进而释放集群资源,避免两个节点争用一个资源的情形发生。保证共享数据的安全性和完整性。
#watchdog /dev/watchdog
#该选项是可选配置,是通过Heartbeat来监控系统的运行状态。使用该特性,需要在内核中载入"softdog"内核模块,用来生成实际的设备文件,如果系统中没有这个内核模块,就需要指定此模块,重新编译内核。编译完成输入"insmod softdog"加载该模块。然后输入"grep misc /proc/devices"(应为10),输入"cat /proc/misc |grep watchdog"(应为130)。最后,生成设备文件:"mknod /dev/watchdog c 10 130" 。即可使用此功能
node node1  #主节点主机名,可以通过命令“uanme –n”查看。
node node2  #备用节点主机名
ping 192.168.12.237
#选择ping的节点,ping 节点选择的越好,HA集群就越强壮,可以选择固定的路由器作为ping节点,但是最好不要选择集群中的成员作为ping节点,ping节点仅仅用来测试网络连接
ping_group group1 192.168.12.120 192.168.12.237
#类似于ping  ping一组ip地址
apiauth pingd  gid=haclient uid=hacluster
respawn hacluster /usr/local/ha/lib/heartbeat/pingd -m 100 -d 5s
#该选项是可选配置,列出与heartbeat一起启动和关闭的进程,该进程一般是和heartbeat集成的插件,这些进程遇到故障可以自动重新启动。最常用的进程是pingd,此进程用于检测和监控网卡状态,需要配合ping语句指定的ping node来检测网络的连通性。其中hacluster表示启动pingd进程的身份。
#下面的配置是关键,也就是激活crm管理,开始使用v2 style格式
crm respawn
#注意,还可以使用crm yes的写法,但这样写的话,如果后面的cib.xml配置有问题
#会导致heartbeat直接重启该服务器,所以,测试时建议使用respawn的写法
#下面是对传输的数据进行压缩,是可选项
compression     bz2
compression_threshold 2
注意,v2 style不支持ipfail功能,须使用pingd代替
资源文件(/etc/ha.d/haresources)
node1   IPaddr::192.168.1.100/24/eth0   httpd
认证文件(/etc/ha.d/authkeys)
auth 1
1 crc

文章作者:yangdonglin 分享原文地址:http://yangdonglin.blog.51cto.com/5404572/1297439

0 个评论

要回复文章请先登录注册