设为首页 收藏本站
查看: 469|回复: 0

[经验分享] 集群 之 LVS + Heartbeat

[复制链接]
发表于 2019-1-3 07:49:14 | 显示全部楼层 |阅读模式
  1.安装ipvsadm
  根据内核版本下载相应的ipvsadm的版本。
[root@zhu1 LVS]# wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz  
[root@zhu1 LVS]# ln -s /usr/src/kernels/2.6.18-194.el5-i686/ /usr/src/linux
[root@zhu1 LVS]# tar zxvf ipvsadm-1.24.tar.gz
[root@zhu1 LVS]# cd ipvsadm-1.24
[root@zhu1 LVS]# make && make install  检查是否安装成功
  
[root@zhu1 LVS]# ipvsadm --help
ipvsadm v1.24 2005/12/10 (compiled with popt and IPVS v1.2.1)
Usage:
ipvsadm -A|E -t|u|f service-address [-s scheduler] [-p [timeout]] [-M netmask]
ipvsadm -D -t|u|f service-address
ipvsadm -C
ipvsadm -R
ipvsadm -S [-n]
ipvsadm -a|e -t|u|f service-address -r server-address [options]
ipvsadm -d -t|u|f service-address -r server-address
ipvsadm -L|l [options]
ipvsadm -Z [-t|u|f service-address]
ipvsadm --set tcp tcpfin udp  若显示帮助信息,则表示安装成功。
  2.安装heartbeat
  heartbeat的安装从3.0版本开始不同,需要先后安装三个包:glub--Resourace Agent--heartbeat
  创建用户和组
  
[root@zhu1 ~]# groupadd haclient
[root@zhu1 ~]# useradd -g haclient hacluster  
  1).安装heartbeat之前需要先安装libnet,它是一个高层次的api工具。
  
[root@zhu1 LVS]# wget http://sourceforge.net/projects/libnet-dev/files/libnet-1.1.6.tar.gz
[root@zhu1 ~]# tar zxvf libnet-1.1.6.tar.gz
[root@zhu1 ~]# cd libnet-1.1.6
[root@zhu1 ~]# ./configure
[root@zhu1 ~]# make && make install  2)安装glub
  安装可能用到的软件包
  
[root@zhu1 LVS]# yum -y install libxslt libxslt-devel libgcrypt-devel autoconf automake pkgconfig  libgpg-error-devel libtool sgml-common opensp openjade xml-common  docbook-dtds docbook-style  
[root@zhu1 LVS]# wget http://hg.linux-ha.org/glue/archive/glue-1.0.9.tar.bz2
[root@zhu1 LVS]# tar jxvf glue-1.0.9.tar.bz2
[root@zhu1 LVS]# cd Reusable-Cluster-Components-glue--glue-1.0.9/
[root@zhu1 Reusable-Cluster-Components-glue--glue-1.0.9]# ./autogen.sh
[root@zhu1 Reusable-Cluster-Components-glue--glue-1.0.9]# ./configure --prefix=/opt/heartbeat
[root@zhu1 Reusable-Cluster-Components-glue--glue-1.0.9]# make && make install  此时容易报错
  
gmake[2]: Entering directory `/root/LVS/Reusable-Cluster-Components-glue--glue-1.0.9/doc'
/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] 错误 4
gmake[2]: Leaving directory `/root/LVS/Reusable-Cluster-Components-glue--glue-1.0.9/doc'
gmake[1]: *** [all-recursive] 错误 1
gmake[1]: Leaving directory `/root/LVS/Reusable-Cluster-Components-glue--glue-1.0.9/doc'
make: *** [all-recursive] 错误 1  解决方法:
  这是由于缺少docbook-style-xsl软件包
  
[root@zhu1 Reusable-Cluster-Components-glue--glue-1.0.9]# yum -y install docbook-style-xsl
[root@zhu1 Reusable-Cluster-Components-glue--glue-1.0.9]# make clean
[root@zhu1 Reusable-Cluster-Components-glue--glue-1.0.9]# make && make install  3)安装Agent
  
[root@zhu1 LVS]# tar zxvf v3.9.2
[root@zhu1 LVS]# cd ClusterLabs-resource-agents-b735277/
[root@zhu1 ClusterLabs-resource-agents-b735277]# ./autogen.sh
此时提示错误
configure.ac:9: error: Autoconf version 2.63 or higher is required  解决方法如下:
  
[root@zhu1 ~]# wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.68.tar.gz
[root@zhu1 ~]# tar zxvf autoconf-2.68.tar.gz
[root@zhu1 ~]# cd autoconf-2.68
[root@zhu1 ~]# ./configure
[root@zhu1 ~]# make && make install  此时再执:
  
[root@zhu1 ~]# cd ClusterLabs-resource-agents-b735277/
[root@zhu1 ~]# ./autogen.sh
会提示错误
autoreconf: automake failed with exit status: 1  解决方法如下:
  
wget http://ftp.gnu.org/gnu/automake/automake-1.11.2.tar.gz
tar zxvf automake-1.11.2.tar.gz
cd automake-1.11.2
./configure
make && make install  
[root@zhu1 ClusterLabs-resource-agents-b735277]# ./autogen.sh
[root@zhu1 ClusterLabs-resource-agents-b735277]# ./configure
[root@zhu1 ClusterLabs-resource-agents-b735277]# make && make install
会提示错误如下  
gmake[2]: *** [metadata-IPv6addr.xml] 错误 127
../heartbeat/IPv6addr: error while loading shared libraries: libplumb.so.2: cannot open shared object file: No such file or directory
gmake[2]: Leaving directory `/root/LVS/ClusterLabs-resource-agents-b735277/doc'
gmake[1]: *** [all-recursive] 错误 1
gmake[1]: Leaving directory `/root/LVS/ClusterLabs-resource-agents-b735277'
make: *** [all] 错误 2  
  解决方法如下:
  
./configure --prefix=/opt/heartbeat/ CFLAGS=-I/opt/heartbeat/include LDFLAGS=-L/opt/heartbeat/lib LIBS='/lib/libuuid.so.1'
[root@zhu1 ClusterLabs-resource-agents-b735277]# vim /etc/ld.so.conf
/usr/local/lib
/opt/heartbeat/lib/
[root@zhu1 ClusterLabs-resource-agents-b735277]#ldconfig  
  这两个是在3.0版本编译时常碰到的错误
  
  4)安装heartbeat
  
[root@zhu1 LVS]# wget http://hg.linux-ha.org/heartbeat-STABLE_3_0/archive/7e3a82377fa8.tar.bz2
[root@zhu1 LVS]# tar jxvf 7e3a82377fa8.tar.bz2
[root@zhu1 LVS]# cd Heartbeat-3-0-7e3a82377fa8/
[root@zhu1 Heartbeat-3-0-7e3a82377fa8]# ./bootstrap
[root@zhu1 Heartbeat-3-0-7e3a82377fa8]# ./ConfigureMe configure --prefix=/opt/heartbeat/
[root@zhu1 Heartbeat-3-0-7e3a82377fa8]# make && make install  此时由于安装路径不是采用默认的,而是指定为安装/opt/heartbeat就会出现找不到库文件的问题
  
In file included from ../include/lha_internal.h:41,
from strlcpy.c:1:
/prog/heartbeat/include/heartbeat/glue_config.h:50:1: error: "HA_SYSCONFDIR" redefined
In file included from ../include/lha_internal.h:38,
from strlcpy.c:1:
../include/config.h:401:1: error: this is the location of the previous definition
In file included from ../include/lha_internal.h:41,
from strlcpy.c:1:
/prog/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:386:1: error: this is the location of the previous definition
gmake[1]: *** [strlcpy.lo] Error 1
gmake[1]: Leaving directory `/prog/heartbeat-3-0-7/replace'
make: *** [all-recursive] Error 1  解决此错误的方法为:
  到opt/heartbeat/include/heartbeak/glue_config.h文件中把第50行,第105行的内容删除即可
  本次对heartbeat安装了两次,建议安装时采用默认的安装路径。
  安装一个插件
  
[root@zhu1 ~]# yum -y install perl-Socket6 perl-libwww-perl perl-URI perl-MailTools perl-HTML-Parser  
  3.创建heartbeat的配置文件
  
[root@zhu1 ~]# cp /opt/heartbeat/share/doc/heartbeat/ha.cf /etc/ha.d/
[root@zhu1 ~]# cp /opt/heartbeat/share/doc/heartbeat/authkeys /etc/ha.d/
[root@zhu1 ~]# cp /opt/heartbeat/share/doc/heartbeat/haresources /etc/ha.d/
[root@zhu1 ~]# cp /opt/heartbeat/etc/ha.d/shellfuncs /etc/ha.d/
[root@zhu1 ~]# cp LVS/Heartbeat-3-0-7e3a82377fa8/heartbeat/init.d/heartbeat /etc/rc.d/init.d/
[root@zhu1 ~]# chkconfig --add heartbeat  ha.cf :heartbeat的主配置文件
  authkeys:双机互连的验证文件
  haresources:集群资源文件。
  4.修改配置文件
  
  
  在主机zhu3上的配置
[root@zhu3 ha.d]# vim /etc/ha.d/ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility     local0
keepalive 8
deadtime 60
warntime 60
initdead 120
udpport 694
baud    19200
ucast eth0 192.168.70.135
auto_failback on
node    zhu3
node    zhu1
respawn hacluster /usr/lib/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster  
[root@zhu3 ha.d]# vim /etc/ha.d/authkeys
auth 1
1 crc  
[root@zhu1 ha.d]# vim haresources
zhu3 lvs IPaddr::192.168.70.70/24/eth0 ldirectord  
root@zhu3 ha.d]# vim /etc/init.d/lvs
#!/bin/bash
VIP=192.168.70.70
/etc/rc.d/init.d/functions
/sbin/ipvsadm --set 10 10 10
case "$1" in
start)
/sbin/ifconfig lo:0 down
/sbin/ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add -host $VIP dev eth0:0
;;
stop)
/sbin/ifconfig eth0:0 down
/sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add -host $VIP dev lo:0
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac  chmod +x /etc/init.d/lvs
  
[root@zhu3 ha.d]# serive heartbeat start
[root@zhu3 ha.d]# ip a
1: lo:  mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:d3:3b:5e brd ff:ff:ff:ff:ff:ff
inet 192.168.70.133/24 brd 192.168.70.255 scope global eth0
inet 192.168.70.70/24 brd 192.168.70.255 scope global secondary eth0:2
inet6 fe80::20c:29ff:fed3:3b5e/64 scope link
valid_lft forever preferred_lft forever
3: sit0:  mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0  在主机zhu1上的配置
  ......
  
  由于zhu1上的安装路径是在/opt/heartbeat/下,所以在启动时常见的错误有
  
  
[root@zhu1 Heartbeat-3-0-7e3a82377fa8]# service heartbeat start
/etc/init.d/heartbeat: line 53: /etc/ha.d/shellfuncs: 没有那个文件或目录
解决方法:
[root@zhu1 Heartbeat-3-0-7e3a82377fa8]# cp /opt/heartbeat/etc/ha.d/shellfuncs /etc/ha.d/
[root@zhu1 Heartbeat-3-0-7e3a82377fa8]# service heartbeat start
/etc/ha.d/shellfuncs: line 96: /usr/lib/ocf/lib//heartbeat/ocf-shellfuncs: 没有那个文件或目录
修改文件中行的路径
. /opt/heartbeat/usr/lib/ocf/lib//heartbeat/ocf-shellfuncs
[root@zhu1 Heartbeat-3-0-7e3a82377fa8]# ln -s /opt/heartbeat/usr/lib/ocf /usr/lib/ocf  
  测试高可用性
  
[root@zhu3 ~]# ip a
1: lo:  mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:d3:3b:5e brd ff:ff:ff:ff:ff:ff
inet 192.168.70.133/24 brd 192.168.70.255 scope global eth0
inet 192.168.70.70/24 brd 192.168.70.255 scope global secondary eth0:2
inet6 fe80::20c:29ff:fed3:3b5e/64 scope link
valid_lft forever preferred_lft forever
3: sit0:  mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0  
root@zhu1 ~]# ip a
1: lo:  mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:ba:9d:f1 brd ff:ff:ff:ff:ff:ff
inet 192.168.70.135/24 brd 192.168.70.255 scope global eth0
inet6 fe80::20c:29ff:feba:9df1/64 scope link
valid_lft forever preferred_lft forever
3: sit0:  mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0  
[root@zhu3 ~]# service heartbeat stop
Stopping High-Availability services:                       [  OK  ]
[root@zhu3 ~]# ip a
1: lo:  mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:d3:3b:5e brd ff:ff:ff:ff:ff:ff
inet 192.168.70.133/24 brd 192.168.70.255 scope global eth0
inet6 fe80::20c:29ff:fed3:3b5e/64 scope link
valid_lft forever preferred_lft forever
3: sit0:  mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
[root@zhu1 ~]# ip a
1: lo:  mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:ba:9d:f1 brd ff:ff:ff:ff:ff:ff
inet 192.168.70.135/24 brd 192.168.70.255 scope global eth0
inet 192.168.70.70/24 brd 192.168.70.255 scope global secondary eth0:0
inet6 fe80::20c:29ff:feba:9df1/64 scope link
valid_lft forever preferred_lft forever
3: sit0:  mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-658778-1-1.html 上篇帖子: Centos5.5下lvs+heartbeat+ldirectord 下篇帖子: 整合heartbeat+lvs
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表