Lvs网络负载均衡 隧道(ip tunl)
win7网络配置200.168.10.4 255.255.255.0
lvs server
#ifconfig eth0 200.168.10.1
#ifconfig eth1 down
webserver1
#route del default
#ifconfig eth0 200.168.10.2
webserver2
#ifconfig eth0 200.168.10.3
#route del default
server、web1、web2都使用vmnet1网卡,关闭防火墙,启动apache
vip配置虚拟ip(在lvs server中)
#ifconfig tunl(小写字母l)0 200.168.10.10netmask 255.255.255.255 up
#route add -host 200.168.10.10 dev tunl0
使用route -n,ifconfig tunl0分别查看配置情况
地址转换脚本
#vi ipvs.sh
# /bin/bash
# ipvs.sh
ipvsadm -C
ipvsadm -At 200.168.10.10:80 -s rr
ipvsadm -at 200.168.10.10:80 -r 200.168.10.2:80 -i
ipvsadm -at 200.168.10.10:80 -r 200.168.10.3:80 -i
ipvsadm -L -n
#chmod a+x ipvs.sh
#./ipvs.sh
webserver1、webserver2配置
#vi arp.sh
# /bin/bash
# arp.sh
ifconfig tunl0 200.168.10.10 netmask 255.255.255.255 up
route add -host 200.168.10.10 dev tunl0
echo 1 >/proc/sys/net/ipv4/conf/tunl0/arp_ignore
echo 2 >/proc/sys/net/ipv4/conf/tunl0/arp_announce
echo 3 >/proc/sys/net/ipv4/conf/all/arp_ignore
echo 4 >/proc/sys/net/ipv4/conf/all/arp_announce
#chmod a+x arp.sh
#./arp.sh
浏览器 200.168.10.10,刷新页面查看轮询访问效果
lsv server
#ipvsadm -L -n 查看访问的情况
页:
[1]