RHEL6上配置基于Heartbeat+LVS+ldirectord的高可用服务(2)

                real=192.168.50.173:80 gate  #此项在有更多真实节点时自由添加

                fallback=127.0.0.1:80 gate

                service=http

                scheduler=rr

                #persistent=600

                #netmask=255.255.255.255

                protocol=tcp

                checktype=negotiate

                checkport=80

                request="index.html"   #向真实服务器请求的网页文件名

                receive="Test Page"    #从真实服务器返回的网页内容,当检测不到此网页文件或返回的内容不正确时即认为真实 节点down

                #virtualhost=www.x.y.z

5)编辑cluster脚本文件(此脚本要放在/etc/init.d)下

 [root@masterheartbeat-2.1.3]# vi /etc/init.d/cluster

#!/bin/bash

#description:start LVS of DirectorServer

#Writtenby qiu

# define used ip.

GW=192.168.50.254

VIP=192.168.50.179

RIP1=192.168.50.172

RIP2=192.168.50.173

./etc/rc.d/init.d/functions

 

case"$1" in

start)

#Clear all ipvsadmrules.

/sbin/ipvsadm -C

#set lvs vip fordr

/sbin/ipvsadm--set 30 5 60

/sbin/ifconfigeth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up

/sbin/route add-host $VIP dev eth0:0

/sbin/ipvsadm -A-t $VIP:80 -s rr -p 3  #-p选项设置session保持时间

/sbin/ipvsadm -a-t $VIP:80 -r $WEB_RIP1:80 -g -w 1

/sbin/ipvsadm -a-t $WEB_VIP:80 -r $RIP2:80 -g -w 1

touch/var/lock/subsys/ipvsadm > /dev/null 2>&1

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/07e0792c002b04cc7e9a820ddf9357db.html