Three virtual machines to do LVS load balancing experiment, VM01 is load balancer, only a network card, VM02 and vm03 are real Web servers, their relationship, here and the NAT mode of the difference between the LVS is the server IP address can be in a network segment. This is the legendary Tun tunnel model.
Vm01
eth0:192.168.1.200
vip:192.168.1.30
Vm02
eth1:192.168.1.201
Vm03
eth1:192.168.1.202
First, Load balancer installation
Ipvs is the foundation of the entire load balancing, and without this foundation, fault isolation and failover are meaningless
[Root@vm01 ~]# Yum install-y ipvsadm
[Root@vm01 ~]# lsmod |grep Ip_vs
[Root@vm01 ~]# modprobe Ip_vs
[Root@vm01 ~]# lsmod |grep Ip_vs
Ip_vs 122241 0
It is not up to the process to judge if the Ip_vs module is loaded, because here is a command and no process is generated.
Second, create the LVs Tun mode startup script
[Root@vm01 ~]# Vim/etc/init.d/lvstun
#!/bin/bash
vip=192.168.1.30
rip1=192.168.1.201
rip2=192.168.1.202
Case "$" in
Start
echo "Start LVS of Directorserver Tun"
/sbin/iptables-f
/sbin/ipvsadm-c
/sbin/ifconfig tunl0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add-host $VIP Dev tunl0
/sbin/ipvsadm-a-T $VIP: 80-s RR
/sbin/ipvsadm-a-T $VIP: 80-r $RIP 1-i
/sbin/ipvsadm-a-T $VIP: 80-r $RIP 2-i
/sbin/ipvsadm
;;
Stop
echo "Stop LVS of Directorserver Tun"
echo "0" >/proc/sys/net/ipv4/ip_forward
/sbin/ipvsadm-c
/sbin/ifconfig tunl0 Down
;;
*)
echo "Error"
Exit 1
Esac
[ROOT@VM01 ~] #chmod A+x/etc/init.d/lvstun
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/virtualization/