Linux load Balancing: LVS Technology

Source: Internet
Author: User

One, the LVS technology main 3 kinds of ways

1, Nat (address translation technology)

Through network address translation, the LVS Scheduler rewrites the destination address of the request message and assigns the request to the backend real Web server according to the set scheduling algorithm. The corresponding message of the real server is rewritten again by the dispatcher and returned to the client to complete the load dispatch process.

This way, LVS need 2 network cards, the left for the public network port address, the right for the Intranet section, requests and corresponding must go through LVS address conversion, so it is possible that LVS will create bottlenecks.

#lvs NAT Service Configuration
#开启路由管道
echo 1>/proc/sys/net/ipv4/ip_forward
#清除以前调度策略
ipvsadm-c
# A scheduling algorithm that adds an algorithm to RR
ipvasdm-at 8.8.8.8:80-s rr
#轮询规则-M for Nat technology
Ipvsadm-at 8.8.8.8:80-r 192.168.10.2:80-m
Ipvsadm-at 8.8.8.8:80-r 192.168.10.3:80-m

2, Ip-tun (IP tunneling Technology)

In order to solve the problem of the bottleneck in the NAT technology, LVS transmits the request message to the real Web server through the IP tunnel, and the real server returns the response directly to the client, so LVS only processes the request message. But the response of the network is much larger than the request message, so the tunnel mode can improve the throughput of the cluster system greatly.

This requires that the Web is really the server's IP address can not be in the intranet address, but the public network IP. At the same time, the LVS server and the Web server have a support Tunnel protocol network card to work, but not many servers have this network card, this is a great limitation.

#配置lvs隧道网卡
ifconfig tunl0 200.168.10.10 netmask 255.255.255.255 up
#添加路由
Route add-host 200.168.10.10
ipvsadm-c
ipvsadm-a-t 200.168.10.10:80-s rr
ipvsadm-a-t 200.168.10.10:80-r
200.168.10.2-i Ipvsadm -a-t 200.168.10.10:80-r 200.168.10.3-i
#配置web服务器
ifconfig tunl0 200.168.10.10 netmask 255.255.255.255 up
#添加路由
Route add-host 200.168.10.10 Dev Tunl0
#添加广播忽略
echo 1>/proc/sys/net/ipv4/conf/tunl0/arp_ignore
echo 2>/proc/sys/net/ipv4/ Conf/tunl0/arp_announce
echo 1>/proc/sys/net/ipv4/conf/all/arp_ignore
echo 2>/proc/sys/net/ipv4/ Conf/all/arp_announce

3, Dr Technology (direct routing technology)

Direct routing technology and tunnel mode is very similar, but he does not have to have the server to support the Tunnel Protocol network card, but through the loopback interface, namely loopback interface settings to achieve.

#配置lvs
ifconfig eth0:0 200.168.10.10 netmask 255.255.255.255 up
#添加路由
Route add-host 200.168.10.10
eth0:0 ipvsadm-c
ipvsadm -A-T 200.168.10.10:80-s rr
ipvsadm-a-t 200.168.10.10:80-r 200.168.10.2-g
ipvsadm-a-T 200.168.10.10:80-r 2 00.168.10.3-g
#配置web服务器
ifconfig lo:0 200.168.10.10 netmask 255.255.255.255 up
#添加路由
route add-host 200.168.10.10 Dev 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

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

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.