LVS keepalived
2016-07-11 17:20:57   来源:   评论:0 点击:

lvs(centos5 6x64)yum install ipvsadmLVS server (ipvsadm安装机器,使用keeplivead无需配置 LVS server脚本) ! bin bashRIP1=172 16

lvs(centos5.6x64)

yum install ipvsadm

LVS server (ipvsadm安装机器,使用keeplivead无需配置 LVS server脚本)

#!/bin/bash

RIP1=172.16.0.151

RIP2=172.16.0.152

VIP1=172.16.0.73

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

case "$1" in

start)

echo " start LVS of DirectorServer"

# set the Virtual IP Address and sysctl parameter

/sbin/ifconfig eth0:0 $VIP1 broadcast $VIP1 netmask 255.255.255.255 up

#/sbin/ifconfig eth0:1 $VIP2 broadcast $VIP2 netmask 255.255.255.255 up

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

#/sbin/route add -host $VIP2 dev eth0:1

echo "1" >/proc/sys/net/ipv4/ip_forward

#Clear IPVS table

/sbin/ipvsadm -C

#set LVS

#Web Apache

/sbin/ipvsadm -A -t $VIP1:80 -s rr -p 120

/sbin/ipvsadm -a -t $VIP1:80 -r $RIP1:80 -g #-g 表示使用DR方式,-m表示NAT方式,-i表示tunneling方式。

/sbin/ipvsadm -a -t $VIP1:80 -r $RIP2:80 -g

#Run LVS

/sbin/ipvsadm

;;

stop)

echo "close LVS Directorserver"

echo "0" >/proc/sys/net/ipv4/ip_forward

/sbin/ipvsadm -C

/sbin/ifconfig eth0:0 down

;;

*)

echo "Usage: $0 {start|stop}"

exit 1

esac

RIP server (真实机器需配置脚本)

#!/bin/bash

#description:start realserver

#chkconfig

VIP1=172.16.0.73

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

case "$1" in

start)

echo " start LVS of REALServer"

/sbin/ifconfig lo:0 $VIP1 broadcast $VIP1 netmask 255.255.255.255 up

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

;;

相关热词搜索:lvs

上一篇:Linux 删除\编辑 -开头的文件
下一篇:最后一页