Linux之LVS集群DR模型实验
Posted orcsir
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux之LVS集群DR模型实验相关的知识,希望对你有一定的参考价值。
LVS-DR模型实现http负载均衡集群,VIP与DIP/RIP不在同一网络。
不废话原理,网上一堆一堆的。直接上拓扑和配置脚本。
网络拓扑如下:
1.DR配置脚本:
1 #!/bin/bash 2 # 3 # DR配置脚本 4 5 vip=‘10.0.0.200‘ 6 iface=‘eth1:0‘ 7 mask=‘255.255.255.255‘ 8 port=‘80‘ 9 rs1=‘172.16.0.101‘ 10 rs2=‘172.16.0.102‘ 11 scheduler=‘wrr‘ 12 type=‘-g‘ 13 14 case $1 in 15 start) 16 ifconfig $iface $vip netmask $mask 17 iptables -F 18 19 ipvsadm -A -t ${vip}:${port} -s $scheduler 20 ipvsadm -a -t ${vip}:${port} -r ${rs1} $type -w 1 21 ipvsadm -a -t ${vip}:${port} -r ${rs2} $type -w 1 22 echo "The VS Server is Ready!" 23 ;; 24 stop) 25 ipvsadm -C 26 ifconfig $iface down 27 echo "The VS Server is Canceled!" 28 ;; 29 *) 30 echo "Usage: $(basename $0) start|stop" 31 exit 1 32 ;; 33 esac
2.RS配置脚本:
1 #!/bin/bash 2 # 3 #RS配置脚本 4 5 vip=10.0.0.200 6 mask=‘255.255.255.255‘ 7 dev=lo:1 8 case $1 in 9 start) 10 echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore 11 echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore 12 echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce 13 echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce 14 ifconfig $dev $vip netmask $mask 15 echo "The RS Server is Ready!" 16 ;; 17 stop) 18 ifconfig $dev down 19 echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore 20 echo 0 > /proc/sys/net/ipv4/conf/lo/arp_ignore 21 echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce 22 echo 0 > /proc/sys/net/ipv4/conf/lo/arp_announce 23 echo "The RS Server is Canceled!" 24 ;; 25 *) 26 echo "Usage: $(basename $0) start|stop" 27 exit 1 28 ;; 29 esac
3.实验结果
1 [[email protected] ~]#curl 10.0.0.200 2 RS_1 3 [[email protected] ~]#curl 10.0.0.200 4 RS_2 5 [[email protected] ~]#curl 10.0.0.200 6 RS_1 7 [[email protected] ~]#curl 10.0.0.200 8 RS_2 9 [[email protected] ~]#
以上是关于Linux之LVS集群DR模型实验的主要内容,如果未能解决你的问题,请参考以下文章
集群lvs-dr应用之wordpress(共享后台MySQL存储)
LB(Load balance)负载均衡集群--{LVS-[NAT+DR]单实例实验+LVS+keeplived实验} 菜鸟入门级