Linux LVS configuration instance based on NAT

Source: Internet
Author: User
LVS is short for linuxvirtualserver. It is a linux-based server cluster solution developed and led by Zhang wensong, a Chinese programmer, its purpose is to create a system with good scalability, high availability and high performance. LVS is implemented by three common systems: 1. DR: (DirectRouting)

LVS is short for linux virtual server. It is headed by Zhang wensong, a Chinese programmer. Based onLinuxThe purpose of the server cluster solution is to create a system with good scalability, high availability and high performance.

LVS is implemented by three common systems

1. DR mode: (Direct Routing) Direct Routing Mode

The principle is: the request data packets of the client reach the DR (Server Load balancerData packets are not processed by DR. data packets are transferred to the real server based on their own hash cache tables. The response data packets sent from the real server to the client are no longer processed by DR, reply directly to the customer!

2. IP Tunneling Mode

Analysis Principle: When the request data packet of the client reaches the DR, the DR re-encapsulates the data packet and transmits it to the real server in a tunnel mode. The real server's response to the client also does not pass through the DR.

3. NAT Mode

The principle is: when the request data packet of the client reaches the DR, the DR performs NAT address conversion to convert the VIP to the ip address of a real server, and the real server responds to the data packet of the client, it also needs to go through the sourcea of DRDdOnly after the conversion of ress and destination address can a client be returned

Here, this experiment is a NAT instance. Due to restrictions, the real server settings are not described here, and only the settings on the most critical DR are performed.

Here we use the RHEL5.4 test platform, kernel version 2.6.18-164. el5xen. Because the system kernel already supports LVS by default, we will not compile the kernel here.

We only use related kits to implement the LVS load balancing function!

Required kit iplvsadmin

The procedure is as follows:

 

[Root @ localhost src] #Pwd
/Usr/src
[Root @ localhost src] # ll ipvsadm-1.24.tar.gz
-Rw-r -- 1 root 36598 Oct 22 2011 ipvsadm-1.24.tar.gz

[Root @ localhost src] #Ln-S kerneLs/2.6.18-164. el5xen-i686/linux
[Root @ localhost src] # tar zxvf ipvsadm-1.24.tar.gz

[Root @ localhost src] #CdIpvsadm-1.24
[Root @ localhost ipvsadm-1.24] # make all & make install

[Root @ localhost ~] # Ipvsadm-C (clear cache)

[Root @ localhost ~] # Ipvsadm-A-t 59.69.141.91: 80-s rr (set the external port of DR to VIP,-t to TCP,-s to algorithm settings, here, the rr (round robin algorithm) is used ))
[Root @ localhost ~] # Ipvsadm-a-t 59.69.141.91: 80-r 192.168.1.192: 80-m-w 1 (add real server,-a indicates add,-t indicates TCP protocol, -m indicates MASQUERADE in disguise, and-w indicates weight)

[Root @ localhost ~] # Ipvsadm-a-t 59.69.141.91: 80-r 192.168.1.193: 80-m-w 1

In this way, you can access IE (http: // 59.69.141.91, And the refresh will display different pages)

[Root @ localhost ~] # Ipvsadm-L-n (view process)

Summary: Here is only the settings on the DR. real server can set the web (apache/nginx), not complex, but functional implementation, because it is only to verify LVS.

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.