标签:arp 调度 1.3 ast src nbsp adb content lan
安装具体解释:http://blog.csdn.net/CleverCode/article/details/50586957。
lvs有三种模式dr,nat,tun。这里先介绍dr模式。
#!/bin/sh # lvs-dr.sh # # lvs的dr模式LVS server脚本 # # # vip和rip必须在同一个网段。VS/DR通过改写请求报文的MAC地址。将请求的包发送到realserver上。 # 不改变包的源和目标的IP地址。然后realserver直接回复client。不再经过LVS调度器,这样大大的减轻了LVS的负担。
# set the vip and port VIP=192.168.142.211 VPORT1=80 # set the rip and port # web RIP1=192.168.142.130 RIP2=192.168.142.131 # port RPORT1=80 Usage (){ echo "Usage:`basename $0` (start|stop|status) " exit 1 } if [ $# -ne 1 ];then Usage fi case $1 in start) echo "start LVS of DirectorServer" echo 1 > /proc/sys/net/ipv4/ip_forward # set the vip /sbin/ifconfig eth0:1 $VIP broadcast $VIP netmask 255.255.255.255 up /sbin/route add -host $VIP dev eth0:1 # clear ipvs table /sbin/ipvsadm -C # add lvs vip and port /sbin/ipvsadm -A -t $VIP:$VPORT1 -s rr # add rip and port /sbin/ipvsadm -a -t $VIP:$VPORT1 -r $RIP1:$RPORT1 -g -w 1 /sbin/ipvsadm -a -t $VIP:$VPORT1 -r $RIP2:$RPORT1 -g -w 1 /sbin/ipvsadm -L -n ;; stop) echo "close LVS DirectorServer" /sbin/ipvsadm -C /sbin/ifconfig eth0:1 down ;; status) /sbin/ipvsadm -L -n ;; *) Usage esac
# cd /usr/local/lvs
# vi realServer.sh
#!/bin/sh # realServer.sh # # lvs的dr模式RIP server脚本 # VIP=192.168.142.211 #vip's broadcast BROADCAST=192.168.142.255 Usage () { echo "Usage:`basename $0` (start|stop)" exit 1 } if [ $# -ne 1 ];then Usage fi case $1 in start) echo "reparing for Real Server" echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce echo "1" >/proc/sys/net/ipv4/conf/eth0/arp_ignore echo "2" >/proc/sys/net/ipv4/conf/eth0/arp_announce /sbin/ifconfig lo:0 $VIP netmask 255.255.255.255 broadcast $BROADCAST up /sbin/route add -host $VIP dev lo:0 ;; stop) /sbin/ifconfig lo:0 down echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce echo "0" >/proc/sys/net/ipv4/conf/eth0/arp_ignore echo "0" >/proc/sys/net/ipv4/conf/eth0/arp_announce echo "stop Real Server" ;; *) Usage esac
5)刷新页面将会看到不同的内同。
标签:arp 调度 1.3 ast src nbsp adb content lan
原文地址:http://www.cnblogs.com/clnchanpin/p/7049721.html