最新消息:

LVS+Heartbeat安装部署文档

未分类 admin 2751浏览 0评论

所需软件:

ipvsadm-1.24-10.x86_64.rpm
heartbeat-2.1.3-3.el5.centos.x86_64.rpm
heartbeat-pils-2.1.3-3.el5.centos.x86_64.rpm
heartbeat-stonith-2.1.3-3.el5.centos.x86_64.rpm
PyXML-0.8.4-4.x86_64.rpm

系统环境:
CentOS 5.4 64-bit

HA1                    10.0.0.108
HA1                    10.0.0.109
web1                   10.0.0.110
web2                   10.0.0.111
VIP                    10.0.0.100

ipvsadm-1.24安装

rpm -ivh ipvsadm-1.24-10.x86_64.rpm
/sbin/ipvsadm

heartbeat 安装

rpm -ivh heartbeat-pils-2.1.3-3.el5.centos.x86_64.rpm
rpm -ivh heartbeat-stonith-2.1.3-3.el5.centos.x86_64.rpm
rpm -ivh PyXML-0.8.4-4.x86_64.rpm
rpm -ivh heartbeat-2.1.3-3.el5.centos.x86_64.rpm

注:若heartbeat一次未安装好,再装一次

rpm -q heartbeat -d              //查看安装路径

echo “service heartbeat start” >> /etc/rc.local


配置heartbeat

cd /usr/share/doc/heartbeat-2.1.3/
cp authkeys ha.cf haresources /etc/ha.d/
cd /etc/ha.d
vi authkeys

#去掉注释      设置校验模式
auth 1
1 crc
#2 sha1 HI!
#3 md5 Hello!

echo “10.0.0.108  HA1” >>/etc/hosts
echo “10.0.0.109  HA2” >>/etc/hosts
vi haresources

#添加:(约44行下面)
HA1 10.0.0.100 vip.sh

vi ha.cf
#去掉注释(约95行)

bcast   eth0

#去掉注释并修改(约125行)

ucast eth0 10.0.0.109

#去掉注释并修改(约215、216行)

node    HA1
node    HA2

chmod 600 authkeys
vi /etc/init.d/vip.sh
#/sbin/bash!
ifconfig eth0:0 10.0.0.100 broadcast 10.0.0.100 netmask 255.255.255.255 up
route add -host 10.0.0.100 dev eth0:0
#setup ipvs
ipvsadm -C
ipvsadm -A -t 10.0.0.100:80 -s rr
ipvsadm -a -t 10.0.0.100:80 -r 10.0.0.110 -g
ipvsadm -a -t 10.0.0.100:80 -r 10.0.0.111 -g
ipvsadm

HA2的配置和HA1一样,可以直接上传HA1的authkeys ha.cf haresources三个文件

sftp 10.0.0.108

cd /etc/ha.d
get authkeys ha.cf haresources
quit

修改HA2中ha.cf里(约125行)为:

ucast eth0 10.0.0.108

把vip.sh放到LVS服务器

vi /etc/init.d/vip.sh           //放到这里开机自启动
chmod 755 /etc/init.d/vip.sh
/etc/init.d/vip.sh

echo “service heartbeat start” >> /etc/rc.local

lvs.sh

#/sbin/bash!
ifconfig lo:0 10.0.0.100 broadcast 10.0.0.100 netmask 255.255.255.255 up
route add -host 10.0.0.100 dev lo:0
echo “1”>/proc/sys/net/ipv4/conf/lo/arp_ignore
echo “2”>/proc/sys/net/ipv4/conf/lo/arp_announce
echo “1”>/proc/sys/net/ipv4/conf/all/arp_ignore
echo “2”>/proc/sys/net/ipv4/conf/all/arp_announce
sysctl -p

web1  web2安装WEB服务

安装过程略

注:

把lvs.sh放到WEB服务器

#vi /etc/init.d/lvs.sh           //放到这里开机自启动
#chmod 755 /etc/init.d/lvs.sh
#/etc/init.d/lvs.sh

得出结论:
不断刷新10.0.0.100,会轮流显示web1和web2页面

转载请注明:爱开源 » LVS+Heartbeat安装部署文档

您必须 登录 才能发表评论!