The Tun model experiment of LVS

Source: Internet
Author: User

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.