$IPVSADM -a -t 10.144.43.185:8080 -r 10.144.43.175 -w 5 -g
$IPVSADM -a -t 10.144.43.185:8080 -r 10.144.43.187 -w 5 -g
$IPVSADM -a -t 10.144.43.185:8080 -r 10.144.43.142 -w 5 -g
fi
;;
stop)
if [ -x $IPVSADM ]
then
#---- 停止LVS Server,但是依然要回复RealServer的身份
$IPVSADM –C
echo 1 >/proc/sys/net/ipv4/conf/all/hidden
echo 1>/proc/sys/net/ipv4/conf/lo/hidden
ifconfig lo:0 10.144.43.185 netmask 255.255.255.255 broadcast 10.144.43.185
route add –host 10.144.43.185 dev lo:0
fi
;;
*)
echo "Usage: lvs {start|stop}"
exit 1
esac
exit 0
4.7修改/etc/ha.d/resource.d/IPaddr 这个shellscript:
在add_interface() subrouteing 中新加入下列三行:
add_interface () {
ipaddr="$1"
ifinfo="$2"
iface="$3"
#
# On Linux the Alias is named ethx:y
# This will remove the "extra" interface Data
# leaving us with just ethx
#
case $SYSTYPE in
*BSD)
IFEXTRA=""
;;
*)
IFEXTRA=`echo "$ifinfo" | cut -f2-`
;;
esac
case $SYSTYPE in
SunOS)
case `uname -r` in
5.8)
$IFCONFIG $iface plumb
CMD="$IFCONFIG $iface inet $ipaddr $IFEXTRA up"
;;
*)
CMD="$IFCONFIG $iface inet $ipaddr $IFEXTRA up"
;;
esac
;;
*BSD)
CMD="$IFCONFIG $iface inet $ipaddr netmask 255.255.255.255 alias"
;;
*)
CMD="$IFCONFIG $iface $ipaddr $IFEXTRA"
;;
esac
ha_log "info: $CMD"
$CMD
# 将subinterface的hidden属性打开,如此可避免ARP问题
echo 1 >/proc/sys/net/ipv4/conf/all/hidden
echo 1 >/proc/sys/net/ipv4/conf/lo/hidden
# 加入预设到VIP的route
route add –host $ipaddr dev $iface
rc=$?
case $rc in
0)
;;
*)
echo "ERROR: $CMD failed."
;;
esac
return $rc
}
4.8至此有关Heartbeat的设定已经完成,记得上述档案在Linux187与linux142上都要一模一样,然后
# setup
将heartbeat的服务设定为启动,之后将两台机器重新开机。
5.在linux187上利用ipvsadm –l检查LVS的Routing Rule,是否如下所示:
[root@Linux187 root]# ipvsadm -l
IP Virtual Server version 1.0.9 (size=65536)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.144.43.185:webcache rr
-> Linux187:webcache Local 5 0 0
阅读(1408) | 评论(0) | 转发(0) |