Go Linux load Balancer software LVS II (Installation article)

Source: Internet
Author: User

First, install the LVS software


1. Pre-Installation Preparation work
Operating system: Unified version Centos4.4.
Address planning, as shown in table 1:
Table 1

More detailed information is shown in 2:

Figure 2 LVS Dr Mode installation Deployment structure diagram


The VIP in Figure 2 refers to the virtual IP address, also called the LVS Cluster service IP, in DR, Tun mode, the packet is returned directly to the user, so, on the director server and on each node of the cluster need to set this address. This IP is typically tied to a loopback address on real server, such as lo:0, and on the director server, the virtual IP is bound on a real network interface device, such as eth0:0.
Each real server can be in the same network segment, or it can be a separate network segment, or it can be multiple servers distributed across the Internet.

2. Install the operating system
Centos4.4 version of Linux, the kernel supports the LVS feature by default, in order to facilitate the compilation and installation of Ipvs management software, when installing the operating system, it is recommended to select the following installation packages:
?  Desktop Environment: Xwindows system, GNOME desktop environment.
?  Development tools: Development tools, X software development, GNOME software, development, KDE software development.
The system is installed, you can check whether kernel has supported the Ipvs module for LVS by following the command:
[[email protected] ~] #modprobe-L |grep Ipvs
/lib/modules/ 2.6.9-42.elsmp/kernel/net/ipv4/ipvs/ip_vs_rr.ko
/lib/modules/2.6.9-42.elsmp/kernel/net/ipv4/ipvs/ip_vs_ Sh.ko
If there is an output similar to the above, the system kernel already supports the Ipvs module by default. You can then install the Ipvs management software.

3. Installing the Ipvs management software on director serve
Ipvs provides the software package has the source code way also has the RPM way, here introduces under the source way installs the Ipvs, first from http://www.linuxvirtualserver.org/software/ ipvs.html download the corresponding version of the Ipvs source, because we use the operating system is the Centos4.4 version, therefore, download the corresponding ipvsadm-1.24 version, followed by the installation:
[[Email protected] ~] #tar zxvf ipvsadm-1.24.tar.gz
[[Email protected] ~] #cd ipvsadm-1.24
[[Email protected] ~] #make
[[Email protected] ~] #make Install
Note: Error compilation information may occur during make, because the compiler cannot find the corresponding kernel, and the following actions will compile correctly:
[[Email protected] ~] #ln-S/usr/src/kernels/2.6.9-42.el-i686//usr/src/linux
You can also download the RPM installation package and install it in RPM mode:
[[Email protected] ~] #rpm –IVH ipvsadm-1.24-6.1.i386.rpm
Then execute:
[Email protected] ~]# Ipvsadm--help
If you see a Help prompt, it indicates that Ipvs has been successfully installed.

4. The use of Ipvsadm
(1) Ipvsadm commonly used syntax and format are as follows:
ipvsadm-a| E-t|u|f Virutal-service-address:port [-S scheduler] [-P [Timeout]] [-M netmask]
ipvsadm-d-t|u|f virtual-service-address
Ipvsadm-c
Ipvsadm-r
Ipvsadm-s [-N]
Ipvsadm-a|e-t|u|f Virtual-service-address:port-r Real-server-address:port
[-g|i|m] [-W weight]
ipvsadm-d-t|u|f virtual-service-address-r real-server-address
ipvsadm-l|l [Options]
Ipvsadm-z [-t|u|f virtual-service-address]
Ipvsadm--set TCP Tcpfin UDP
Ipvsadm–h
which
? Virtual-service-address: Refers to the IP address of the virtual server, this article is 192.168.60.200
? Real-service-address: Refers to the IP address of real server, this article is 192.168.60.132/144
? Scheduler: specifying the scheduling algorithm
The detailed meaning of the ipvsadm command option is shown in table 2:
Table 2
Command options
Meaning
-A (--add-service) adds a new virtual IP record to the list of virtual servers in the kernel. That is, add a new virtual server. Virtual IP is the IP address of the virtual server.
-E (--edit-service) edit a virtual server record in the list of kernel virtual servers
-D (--delete-service) Delete a virtual server record from the list of kernel virtual servers
-C (--clear) clears all records in the kernel virtual server list
-R (--restore) restore virtual Server rules
-S (--save) Save virtual Server rule, output to-r option readable format
-A (--add-server) adds a new real server record to a record in the kernel virtual server list. That is, adding a new real server to a virtual server
-E (--edit-server) edit a real server record in a virtual server record
-D (--delete-server) deletes a real server record in a virtual server record
-l|-l–list displaying a list of virtual servers in the kernel
-Z (--zero) Virtual Server list counter clear 0 (empty the current number of connections, etc.)
--set TCP tcpfin UDP setting Connection timeout value
-T describes the TCP service provided by the virtual server, which is followed by the following format:
[Virtual-service-address:port] or [Real-server-ip:port]
-U indicates that the virtual server provides the UDP service, which is followed by the following format:
[Virtual-service-address:port] or [Real-server-ip:port]
-F Fwmark Description is a service type that has been iptables marked
-s The scheduling algorithm used with LVS after this option
There are several options: Rr|wrr|lc|wlc|lblc|lblcr|dh|sh
The default scheduling algorithm is: WLC
The continuous service time on a real server for-p [timeout]. This means that multiple requests from the same user will be processed by the same real server. This parameter is typically used for operations with dynamic requests, and the default value for timeout is 300 seconds. For example:-P 600, which indicates a continuous service time of 600 seconds.
-r Specifies the IP address of the real server, which is followed by the following format:
[Real-server-ip:port]
-G (--gatewaying) specifies that the LVS work mode is direct route mode (this mode is the LVS default operating mode)
-I (-IPIP) specifies the operating mode of the LVS for tunnel mode
-M (--masquerading) specifies the operating mode of LVS for NAT mode
-W (--weight) weight Specifies the weight of the real server
-C (--connection) displays LVS current connection information such as: Ipvsadm-l-C
-L--timeout Displays the timeout value for "TCP Tcpfin UDP" such as: Ipvsadm-l--timeout
-L--daemon Displays the status of the synchronization daemon, for example: Ipvsadm-l–daemon
-L--stats Displays statistics, for example: Ipvsadm-l–stats
-L--rate Display rate information, for example: Ipvsadm-l--rate
-L--sort sort the output on the virtual server and the real server, for example: Ipvsadm-l--sort

Comments:
In table 2, the contents of the left bracket are ipvsadm long format representations of each option, in the Linux command options, there are long and short formats, short format options are more, the actual application can be used in parentheses in the long format to replace the short format, for example, you can use the "Ipvsadm--clear" Instead of "ipvsadm-c".

(2) Example
[[email protected] ~]# ipvsadm-a-t 192.168.60.200:80-s rr-p 600
The above indicates that a 192.168.60.200 virtual server record is added to the virtual server list in the kernel, and the service port of this virtual server is specified as 80, and then the scheduling policy for this virtual server is the polling schedule, and in each real The duration of service on the server is 600 seconds, or 10 minutes.
[Email protected] ~]# ipvsadm-a-t 192.168.60.188:21-s WLC
The above indicates that a 192.168.60.188 virtual server is added to the list of virtual servers in the kernel, the service port of this virtual server is 21, which is the FTP service. The scheduling policy used is the WLC, which is the weighted least-link algorithm.
[Email protected] ~]# ipvsadm-a-t 192.168.60.200:80-r 192.168.60.132:80–g
[Email protected] ~]# ipvsadm-a-t 192.168.60.200:80-r 192.168.60.144:80–g
The above two settings indicate that two new real server records are added to the virtual server 192.168.60.200, two real server IPs are 192.168.60.132 and 192.168, respectively. 60.144, Parameter "-G" Specifies that the operating mode of the virtual server is the direct route mode, which is the DR mode.
After this is set up, when the user accesses the 192.168.60.200 80 service, LVS assigns the request to the 192.168.60.132 and the 192.168.60.144 80 port according to the scheduling policy and routing mode set.

This article originates from http://ixdba.blog.51cto.com/2895551/554029

Go Linux load Balancer software LVS II (Installation article)

Related Article

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.