此次讲述一下LVS-DR的另一个模型
DIP、RIP属于私有IP地址,VIP属于公网IP,即三者不属于同一网段
架构图:
集群配置
1、Director配置
DIP配置 #ifconfig eth0 192.168.0.170/24 up #route add default gw 192.168.0.254 #ifconfig
Director上配置VIP #ifconfig eth0:0 172.16.249.100 netmask 255.255.255.255 broadcast 172.16.249.100 up
#route add -host 172.16.249.100 dev eth0:0 添加主机路由 #route -n
2、RS1配置
RS1内核参数配置 # 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
配置RS1的RIP #ifconfig eth0 192.168.0.171/24 up #route add default gw 192.168.0.254
配置RS1的VIP #ifconfig lo:0 172.16.249.100 netmask 255.255.255.255 broadcast 172.16.249.100 up #route add -host 172.16.249.100 dev lo:0 #ifconfig
#route -n
配置web #vim /var/www/html <h1>welcome to RS1!</h1> #service httpd restart 关闭防火墙 #service iptables stop
3、 RS2配置
RS2内核参数配置 #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
配置DIP #ifconfig eth0 192.168.0.172/24 up #route add default gw 192.168.0.254 #ifconfig
配置VIP #ifconfig lo:0 172.16.249.100 netmask 255.255.255.255 broadcast 172.16.249.100 up #ifconfig
#route add -host 172.16.249.100 dev lo:0 #route -n
4、 Director 调度器设置集群服务及RS
#ipvsadm -A -t 172.16.249.100:80 -s rr #ipvsadm -a -t 172.16.249.100:80 -r 192.168.0.171 -g #ipvsadm -a -t 172.16.249.100:80 -r 192.168.0.172 -g #ipvsadm -L -n
5、 客户端测试
CIP:192.168.1.100 NETMASK:255.255.255.0 GATEWAY: 192.168.1.254
刷新
总结:LVS-DR 集群模式(二)已成功实现,rr算法已成功实现!
PS:水平有限,有问题请指出共同丰富!