LVS的DR设置测试
#! /bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
ipv=/sbin/ipvsadm
vip=10.222.138.10
rs1=10.222.138.201
rs2=10.222.138.202
ifconfig eth0:1 $vip broadcast $vip netmask 255.255.255.255 up
route add -host $vip dev eth0:1
$ipv -C
$ipv -A -t $vip:80 -s wrr
$ipv -a -t $vip:80 -r $rs1:80 -g -w 3
$ipv -a -t $vip:80 -r $rs2:80 -g -w 1
两台rs上:vim /usr/local/sbin/lvs_dr_rs.sh
#! /bin/bash
vip=10.222.138.10
ifconfig lo:0 $vip broadcast $vip netmask 255.255.255.255 up
route add -host $vip lo:0
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
dir 上
[root@dir network-scripts]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.222.138.10:80 wrr
-> 10.222.138.201:80 Route 3 0 0
-> 10.222.138.202:80 Route 1 0 0
打开另外一台centos ,curl 10.222.138.10来测试
[root@master ~]# curl 10.222.138.10
201.....................
[root@master ~]# curl 10.222.138.10
201.....................
[root@master ~]# curl 10.222.138.10
201.....................
[root@master ~]# curl 10.222.138.10
202----------------------------
[root@master ~]# curl 10.222.138.10
201.....................
[root@master ~]# curl 10.222.138.10
201.....................
[root@master ~]# curl 10.222.138.10
201.....................
[root@master ~]# curl 10.222.138.10
202----------------------------
[root@master ~]# curl 10.222.138.10
201.....................
[root@master ~]# curl 10.222.138.10
201.....................
[root@master ~]# curl 10.222.138.10
201.....................
[root@master ~]# curl 10.222.138.10
202----------------------------
安装权重分别循环显示rs1,rs2的内容