A Dr model of LVS in lb load balancing

Source: Internet
Author: User

The LVS architecture can be logically divided into the scheduling layer (Director), the server cluster layer (Real server), and the shared storage tier

LVS can be divided into three modes of operation :


NAT (The scheduler changes the requested destination IP as the VIP address to the IP of the real server, the returned packets are also routed through the scheduler, and the scheduler then modifies the source address to the VIP) to rely on the firewall

TUN (The scheduler encapsulates the requested packet encryption over the IP tunnel to the back-end real server, and real server returns the data directly to the client without the scheduler)

The DR (the scheduler changes the destination MAC address of the requested packet to the MAC address of the real server, returns without the scheduler, returns it directly to the client), does not rely on the firewall , and returns the data directly to the customer via the extranet .


Three types of Ip:dip (driector IP), VIP (virtual IP), RIP (Real IP). Where dip, RIP for the same

Network segment, and for private IP, VIP for external service ip,director, Real server is set

Vip

LVS Scheduling algorithm: Round call scheduling (Round Robin) (abbreviated RR), weighted round call (Weighted Round

Robin) (WRR), Minimum link (least connection) (LC), weighted least link (Weighted least

Connections) (WLC), etc.


LVS/DR Mode configuration

Three servers one as director, two as real server (Vi/etc/sysconfig/network to host name)

Dir eth0 192.168.239.140 vip eth0:0: 192.168.239.110

Real1 eth0 192.168.239.141 vip lo: 0:192.168.239.110

Real2 eth0 192.168.239.142 vip lo:0: 192.168.239.110

Installation of Httpd:yum install-y Nginx on two real servers

Yum install-y epel-release (no dependencies installed, no boot, or install nginx with yum)

DIRECOTR on vim/usr/local/sbin/lvs_dr.sh//Increase

#! /bin/bash

Echo 1 >/proc/sys/net/ipv4/ip_forward

Ipv=/sbin/ipvsadm

vip=192.168.239.110

rs1=192.168.239.141

rs2=192.168.239.142

Ifconfig eth0:0 down if there is a modification script, the second time use the script to add this command,

Ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up

Route add-host $vip Dev eth0:0

$IPV-C

$IPV-A-t $VIP: 80-s WRR

$IPV-A-t $vip: 80-r $rs 1:80-g-W 1

$IPV-A-t $vip: 80-r $rs 2:80-g-W 1


Script part meaning

echo 1 >/proc/sys/net/ipv4/ip_forward forwarding

Ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up binding VIP

Route add-host $vip Dev eth0:0 Add a route to a VIP

$IPV-c purge rule, the following three lines of the script are the execution rules

WRR algorithm-G for Dr Mode-W 1 weight (without WRR, weight does not take effect)


Two Real on: vim/usr/local/sbin/lvs_dr_rs.sh

#! /bin/bash

vip=192.168.239.110

Ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up

Route Add-host $vip lo:0

echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore

echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce

echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore

echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce


Director Sh/usr/local/sbin/lvs_dr.sh

Real1 sh/usr/local/sbin/lvs_dr_rs.sh

Real2 sh/usr/local/sbin/lvs_dr_rs.sh


3 sets of Ifconfig REAL1/2 will appear lo:0 IP 192.168.239.110

Director will appear eth0:0 IP 192.168.239.110


Director Ipvsadm-ln can view the rules that have been added

Windows under Browser test access 192.168.239.110 Windows Poor performance can be Linux test

Linux systems can test Curl 192.168.239.110 with another machine (assign 1 real1,1 times real2)


If you need to modify the script (assigning weights or other), then execute the script will be error, because the current face executed script, Eth0 has been generated, so DIRECOTR on vim/usr/local/sbin/lvs_dr.sh//Add Red command


Re-execute sh/usr/local/sbin/lvs_dr.sh

Director Ipvsadm-ln can view rules and curl test rules are in effect


This article is from the "11657691" blog, please be sure to keep this source http://11667691.blog.51cto.com/11657691/1784524

A Dr model of LVS in lb load balancing

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.