LVS-DR model implements HTTP Load Balancing cluster, VIP and Dip/rip are not on the same network.
No nonsense principle, a bunch of online piles. Directly on the topology and configuration scripts.
The network topology is as follows:
1.DR configuration script:
1#!/bin/Bash2 #3 # dr Configuration Script4 5vip='10.0.0.200'6Iface='eth1:0'7mask='255.255.255.255'8port=' the'9rs1='172.16.0.101'TenRs2='172.16.0.102' OneScheduler='WRR' AType='- G' - - Case$1 inch the start) - ifconfig$iface $vip netmask $mask -Iptables-F - +Ipvsadm-a-T ${vip}:${port}-s $scheduler -Ipvsadm-a-T ${vip}:${port}-R ${rs1} $type-W 1 +Ipvsadm-a-T ${vip}:${port}-R ${rs2} $type-W 1 A Echo "The VS Server is ready!" at ;; - stop) -Ipvsadm-C - ifconfig$iface Down - Echo "The VS Server is canceled!" - ;; in*) - Echo "Usage: $ (basename $) start|stop" toExit1 + ;; - Esac
2.RS configuration script:
1#!/bin/Bash2 #3 #RS配置脚本4 5vip=10.0.0.2006mask='255.255.255.255'7Dev=lo:18 Case$1 inch9 start)Ten Echo 1>/proc/sys/net/ipv4/conf/all/Arp_ignore One Echo 1>/proc/sys/net/ipv4/conf/lo/Arp_ignore A Echo 2>/proc/sys/net/ipv4/conf/all/arp_announce - Echo 2>/proc/sys/net/ipv4/conf/lo/arp_announce - ifconfig$dev $vip netmask $mask the Echo "The RS Server is ready!" - ;; - stop) - ifconfig$dev Down + Echo 0>/proc/sys/net/ipv4/conf/all/Arp_ignore - Echo 0>/proc/sys/net/ipv4/conf/lo/Arp_ignore + Echo 0>/proc/sys/net/ipv4/conf/all/arp_announce A Echo 0>/proc/sys/net/ipv4/conf/lo/arp_announce at Echo "The RS Server is canceled!" - ;; -*) - Echo "Usage: $ (basename $) start|stop" -Exit1 - ;; in Esac
3. Experimental results
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] ~]#
Experiment of Linux LVS cluster Dr model