负载均衡集群 LVS-DR模型(二)


此次讲述一下LVS-DR的另一个模型

DIP、RIP属于私有IP地址,VIP属于公网IP,即三者不属于同一网段



架构图



wKioL1NaW2jAQDxTAAGJ-qZG5gI137.jpg


集群配置


1、Director配置


DIP配置
#ifconfig eth0 192.168.0.170/24 up
#route add default gw 192.168.0.254
#ifconfig

wKiom1NaXF_CTGCgAAEBJhDxo88307.jpg


Director上配置VIP        
#ifconfig eth0:0 172.16.249.100 netmask 255.255.255.255 broadcast 172.16.249.100 up

wKiom1NaXTbgWRZkAABo5S7Vt0c575.jpg


#route add -host 172.16.249.100 dev eth0:0 添加主机路由
#route  -n


wKioL1NaXWGy6xglAACZt31Epm4747.jpg


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


wKiom1NaXlTxk0bwAAD-iYsFI_I366.jpg


配置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


wKioL1NaXxnwEL_ZAABRZcom34g858.jpg

     #route -n

wKiom1NaX1LRZ9EVAACP3pZjxzM143.jpg



配置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


    wKioL1NaYFvwayrSAAD0S47alUQ690.jpg

   

配置VIP
#ifconfig lo:0 172.16.249.100 netmask 255.255.255.255 broadcast 172.16.249.100 up
#ifconfig

         

    wKioL1NaYRnSiceLAABLiQzHhY0741.jpg

   

#route add -host 172.16.249.100 dev lo:0
#route -n

 

    wKioL1NaYSfA5uUrAACCAytJcIg505.jpg


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

   

   wKioL1NaYdzhh5aNAACMlfBBiGY965.jpg


5、 客户端测试

   

   

CIP:192.168.1.100
NETMASK:255.255.255.0
GATEWAY: 192.168.1.254

     

   wKiom1NaYrvAu4uRAACKXd9DE3A315.jpg

   刷新


   wKiom1NaYs_xu7eFAACK-oRaWXk587.jpg


   

总结:LVS-DR 集群模式(二)已成功实现,rr算法已成功实现!

   

  PS:水平有限,有问题请指出共同丰富!

你可能感兴趣的:(lvs-dr,二,集群实现)