LVS Load Balancing Concept Chapter

Source: Internet
Author: User

First, Brief introduction
LVS is a shorthand for Linux Virtual server and is a highly scalable and highly available cluster solution on Linux servers. Developed by Dr. Zhangwensong, it is now integrated into the Linux kernel module and implements a load balancing schedule of four layers (transport layer) at the kernel level.

Principle:

ii. working mode of LVS

There are three different modes of operation depending on how the backend server returns data:

Mode command option 1, DR (direct routing) default mode, efficiency up to- G--gatewaying2, TUN (tunneling) tunnel mode-I --IPIP3, NAT mode address spoofing- m --masquerading
Three, load balancing scheduling algorithm
1. RR (Round Robin) Poll                2, WRR (Weighted Round Robin)      weighted polling 3, LC (LEAST-CONNECTION)           minimum connection 4, WLC (Weighted least-connection) Weighted least connection (default algorithm) 5, LBLC (locality-based least-connection)   based on local minimum connections are assigned the same RS according to the request IP, if the load weight is assigned the least connected RS, Maintain mappings from a destination IP address to a set of servers 6, LBLCR (locality-based least-connection with Replication), minimally-localized links with replication, maintaining mappings from one destination IP address to one server 7, DH (Destination Hashing)       Destination address hash 8, SH (source Hashing)            Source Address hash 9, SED (shortest expected delay)  the shortest expected delay (clients + 1)/weight 10, NQ (never queue)              minimum queues are allocated directly to RS with a connection number of 0
Iv. installation of Ipvsadm
Ipvsadm is a tool for creating and maintaining kernel LVs tables
1. See if the kernel is integrated with the Ipvs module
Modprobe-l |grep Ipvs
Kernel/net/netfilter/ipvs/ip_vs.kokernel/net/netfilter/ipvs/ip_vs_rr.kokernel/net/netfilter/ipvs/ip_vs_ Wrr.kokernel/net/netfilter/ipvs/ip_vs_lc.kokernel/net/netfilter/ipvs/ip_vs_wlc.kokernel/net/netfilter/ipvs/ip_ vs_lblc.kokernel/net/netfilter/ipvs/ip_vs_lblcr.kokernel/net/netfilter/ipvs/ip_vs_dh.kokernel/net/netfilter/ ipvs/ip_vs_sh.kokernel/net/netfilter/ipvs/ip_vs_sed.kokernel/net/netfilter/ipvs/ip_vs_nq.kokernel/net/ Netfilter/ipvs/ip_vs_ftp.kokernel/net/netfilter/ipvs/ip_vs_pe_sip.ko


2. turn on kernel Routing and forwarding
Sed-i '/net.ipv4.ip_forward/s/0/1/'/etc/sysctl.conf # permanently Open
Sysctl-p # Reload

echo "1" >/proc/sys/net/ipv4/ip_forward # Temporary Open

3, installation mode any one

A, yum installation
Yum Install Ipvsadm

B, compile and install
Yum-y Install popt popt-devel libnl libnl-devel popt-static # Installation Dependency Package

wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz # Download Ipvsadm
TAR-ZXF ipvsadm-1.26.tar.gz
CD ipvsadm-1.26
Make && make install # compile && Install

Chkconfig--add Ipvsadm
Chkconfig Ipvsadm on
Service Ipvsadm Start # Ipvsadm


Five, command options
Ipvsadm-a-T 192.168.18.10:80-s RR # set 192.168.18.10 as an external virtual server, using tcp:80 port, load balancer using round Robin (polling) algorithm
Ipvsadm-a-T 192.168.18.10:80-r 172.17.0.2:80-m # corresponds the tpc:80 port of the backend real server 172.17.0.2 to the virtual server, using NAT mode (masquerading)
Ipvsadm-a-T 192.168.18.10:80-r 172.17.0.3:80-m

Ipvsadm-a-T 192.168.18.10:3306-s RR
Ipvsadm-a-T 192.168.18.10:3306-r 172.17.0.2:3306-m
Ipvsadm-a-T 192.168.18.10:3306-r 192.168.18.11:3306-g

ipvsadm-d-T 192.168.18.10:3306-r 192.168.18.11:3306 # Delete backend server (RS)
IPVSADM-E-T 192.168.18.10:3306-s WRR #-E modifies virtual server, scheduling algorithm for weighted polling
IPVSADM-E-T 192.168.18.10:3306-r 172.17.0.2:3306-w 2-m # Modify the weight of Rs to 2
IPVSADM-E-T 192.168.18.10:3306-r 192.168.18.11-w 12-g # Modify the weight of Rs to 12

IPVSADM-LN #-N displays detailed information in numbers
IPVSADM-LNC #-C Displays the current connection

Ipvsadm-d-T 192.168.18.10:3306 # Delete virtual Server (Associated RS rule also deleted)
Ipvsadm-s > ~/ipvsadm_bak # Backup table rules
Ipvsadm-r < ~/ipvsadm_bak # Restore table rules


For more information:
http://www.linuxvirtualserver.org/
http://www.austintek.com/LVS/LVS-HOWTO/HOWTO/
Http://zh.linuxvirtualserver.org/node/34
Http://keepalived.org/pdf/sery-lvs-cluster.pdf
Http://kb.linuxvirtualserver.org/wiki/Compiling_ipvsadm_on_different_Linux_distributions

LVS Load Balancing Concept Chapter

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.