当前位置: > Linux集群 > 负载均衡SLB >

LVS TUN 模式配置

时间:2014-05-15 01:28来源:linux.it.net.cn 作者:IT网
一、试验拓扑
二、环境描述
负载均衡器:eth0 192.168.152.139
VIP192.168.152.250
web节点IP192.168.152.151 192.168.152.152
三、负载均衡器安装配置
1)安装
#yum -y install ipvsadm
#lsmod | grep ip_vs 查看没有输出
#modprobe ip_vs 安装即可
2)一样这里也写个脚本,#cat /etc/init.d/lvstun
#!/bin/bash
#lvs of TUN
VIP=192.168.152.250
RIP1=192.168.152.151
RIP2=192.168.152.152
case "$1" in
start)
echo "start lvs of TUN"
/sbin/ifconfig tunl0 $VIP broadcast $VIP netmask 255.255.255.0 up
/sbin/route add -host $VIP dev tunl0
/sbin/ipvsadm -C
/sbin/ipvsadm -A -t $VIP:80 -s rr
/sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -i
/sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -i
/sbin/ipvsadm
;;
stop)
echo "stop lvs of TUN"
/sbin/ipvsadm -C
/sbin/ifconfig tunl0 down
;;
*)
echo "Usage :$0 {start|stop}"
exit1
esac
#chmod o+x /etc/init.d/lvstun
#service lvstun start
三、节点服务器配置
节点1,2一样写脚本,# cat /etc/init.d/lvsTUNRIP
#!/bin/bash
#TUN server
VIP=192.168.152.250
case "$1" in
start)
echo "start LVS of TUN"
/sbin/ifconfig tunl0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add -host $VIP dev tunl0
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
;;
stop)
echo "stop LVS of TUN"
/sbin/ifconfig tunl0 down
echo "0" > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo "0" > /proc/sys/net/ipv4/conf/lo/arp_announce
echo "0" > /proc/sys/net/ipv4/conf/all/arp_ignore
echo "0" > /proc/sys/net/ipv4/conf/all/arp_announce
;;
*)
echo "Usage:$0 {start|stop}"
exit 1
esac
 
#chmod o+x /etc/init.d/lvsTUNRIP
#service lvsTUNRIP start
 
四、验证
1)负载均衡器信息
# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.152.250:80 rr
-> 192.168.152.152:80 Tunnel 1 0 0
-> 192.168.152.151:80 Tunnel 1 0 0
2)访问的信息
3)节点的信息
ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:6E:B2:0F
inet addr:192.168.152.151 Bcast:192.168.152.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe6e:b20f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6472 errors:0 dropped:0 overruns:0 frame:0
TX packets:4941 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:610815 (596.4 KiB) TX bytes:611623 (597.2 KiB)
Interrupt:177 Base address:0x1424

 
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:5314 errors:0 dropped:0 overruns:0 frame:0
TX packets:5314 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:947635 (925.4 KiB) TX bytes:947635 (925.4 KiB)

 
tunl0 Link encap:IPIP Tunnel HWaddr
inet addr:192.168.152.250 Mask:255.255.255.255
UP RUNNING NOARP MTU:1480 Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2584 (2.5 KiB) TX bytes:0 (0.0 b)

本文出自 “改变从现在开始” 博客,请务必保留此出处http://peaceweb.blog.51cto.com/3226037/757523

(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容