LVS-DR模型配置
OS |
IP |
子网掩码 |
路由网关 |
Centos6.5 (Directory) |
Eth0:192.168.25.209(DIP) |
255.255.252.0 |
|
Eth0:0:192.168.26.210(VIP) |
255.255.255.255 |
Eth0:0 |
|
OS |
RS |
子网掩码 |
路由网关 |
Centos6.6 (RS1) |
Eth0:192.168.25.210(RIP) |
255.255.252.0 |
192.168.25.3 |
Lo:0:192.168.26.210(VIP) |
255.255.255.255 |
Lo:0 |
|
Centos6.6 (RS2) |
Eth0:192.168.25.211(RIP) |
255.255.252.0 |
192.168.25.3 |
Lo:0:192.168.26.210(VIP) |
255.255.255.255 |
Lo:0 |
|
Centos6.6 (RS3) |
Eth0:192.168.25.212(RIP) |
255.255.252.0 |
192.168.25.3 |
Lo:0:192.168.26.210(VIP) |
255.255.255.255 |
Lo:0 |
|
Win7 |
IP:192.168.25.159(CIP) |
255.255.252.0 |
192.168.25.3 |
配置Directory:
ifconfig eth0 192.168.25.209/22 up
ifconfig eth0:0 192.168.26.210 netmask 255.255.255.255 broadcast 192.168.26.210 up
route add -host 192.168.26.210 dev eth0:0
route -n
RS1:
ifconfig eth0 192.168.25.210/22 up
route add default gw 192.168.25.3 #指定自己网关
#配置系统内核参数:
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce
ifconfig lo:0 192.168.26.210 netmask 255.255.255.255 broadcast 192.168.26.210 up
route add -host 192.168.26.210 dev lo:0
curl 192.168.26.210
curl 192.168.25.210
RS2配置:
ifconfig eth0 192.168.25.211/22 up
route add default gw 192.168.25.3
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce
ifconfig lo:0 192.168.26.210 netmask 255.255.255.255 broadcast 192.168.26.210 up
route add -host 192.168.26.210 dev lo:0
curl 192.168.26.210
curl 192.168.25.211
RS3配置:
ifconfig eth0 192.168.25.212/22 up
route add default gw 192.168.25.3
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce
ifconfig lo:0 192.168.26.210 netmask 255.255.255.255 broadcast 192.168.26.210 up
route add -host 192.168.26.210 dev lo:0
curl 192.168.26.210
curl 192.168.25.212
回到Directory进行LVS配置:
ipvsadm -A -t 192.168.26.210:80 -s rr
ipvsadm -a -t 192.168.26.210:80 -s 192.168.25.210 -g
ipvsadm -a -t 192.168.26.210:80 -s 192.168.25.211 -g
ipvsadm -a -t 192.168.26.210:80 -s 192.168.25.212 -g
ipvsadm -L -n #查看LVS配置信息
测试VIP是否可用。
访问测试:通过多次刷新观察变化情况。
查看访问后LVS状态: