Realize Linux clusters with LVS software under Linux

xiaoxiao2021-03-06  110

This article describes the Cluster software LVS under Linux and an example of the installation and implementation of the Cluster under Linux. . Today, in various network services, today, with the increase in network speed and the increase in users, in some busy occasions, single machines can not be able to cope with all network requests. In order to solve this problem, many users use a group of Cluster to replace a single machine. Cluster can connect multiple computers to work together to provide a variety of services, such as Apache, FTP, Mail, etc.

The most common on Linux, or the most widely used Cluster scheme is LVS (Linux Virtual Server), very happy LVS is also an open source project for Chinese creation and development. Since 1998, LVS has developed to a relatively mature technical project. There are many more famous websites and organizations that use LVS erected Cluster, such as: www.linux.com, sourceforge.net, www.real.com, etc.

Here, you will now introduce how the author uses the LVS to set a group of Cluster to provide Apache and FTP services.

Install the operating system

The author chooses Red Hat 9.0 as some CLUSTER's Director machine and all REAL Server machine operating systems. The installation process of RH is slightly, and the author only has a few packages according to actual needs. For batch installation Linux, it is recommended to try Kickstart to enter the approach installation.

Compile support LVS kernel

LVS modifies and adds Linux's kernel, so you have to recompile Linux Kernel. Let's download from http://www.linuxvirtualserver.org to the LVS kernel patch, update the original kernel source code, and recompile Linux's kernel.

When downloading the LVS kernel patch, pay attention to the patch version to be consistent with the Kernel version. For RH9.0, its Linux core version is 2.4.20, so the corresponding kernel patch should be http://www.linuxvirtualserver.org/software/ Kernel-2.4 / linux-2.4.20-ipvs-1.0.9.patch.gz

There is another patch to solve some cases where the ARP protocol does not work properly, from http://www.ssi.bg/~ja/hidden-2.4.20pre10-1.diff.

Copy the two patches downloaded to the / usr / src directory and do the following command:

CD / usr / src gzip -cd Linux-2.4.20-ipvs-1.0.9.patch.gz CD / USR / SRC / Linux Patch -p1 <../linux-2.4.20-ipvs-1.0.9.patch PATCH -P1 <../hidden-2.4.20pre10-1.diff

Make Mrproperty Make MenuConfig

When performing Make MenuConfig, we will enter a graphical interface where you can set the Linux Kernel. In "Networking Options" in "Networking Options", the LVS is entered "Networking Options", you can check the IP: Virtual Server Configuration option, select all the other sub-options:

virtual server support (EXPERIMENTAL) [*] IP virtual server debugging (12) IPVS connection table size (the Nth power of 2) --- IPVS scheduler round-robin scheduling weighted round-robin scheduling least-connection scheduling scheduling weighted least-connection scheduling locality-based least-connection scheduling locality-based least-connection with replication scheduling destination hashing scheduling source hashing scheduling Shortest Expected Delay Scheduling Never Queue Scheduling --- IPVS Application Helper FTP Protocol Helper In addition, all child items in "IP: Netfilter Configuration" in "Networking Options", except for two Don't choose, other all available:

<> Ipchains (2.2-style) Support <> ipfwadm (2.0-style) Support

Also, there are some options for the network in "NetWorking Options". Pay attention to your needs:

<*> Packet socket [] Packet socket: mmapped IO <*> Netlink device emulation [*] Network packet filtering (replaces ipchains) [*] Network packet filtering debugging [*] Socket Filtering <*> Unix domain sockets [*] TCP / Ip networking [*] ip: multicasting [*] ip: advanced router [*] ip: policy routing [] ip: use netfilter mark value as routing key [] IP: Fast Network Address Translation ip: tunneling

For other options for Kernel, you can choose as needed. Kernel's configuration is a very important job, careful and patience, and improper configuration may cause errors in the compilation process or new Kernel can't drive the original equipment.

Exit save, then continue to perform the following command:

Make Dep Make Clean Make Bzimage Make Make Make Make Make Make Make Make Make Makes_Install may take a little time, if you want to check your kernel configuration, continue to perform the following command if no error occurs:

DEPMOD -A CP Arch / I386 / Boot / Bzimage / Boot / VMLinuz-LVS CP System.map /Boot/system.map-lvs

CD / boot rm system.map ln-s system.map-lvs system.map

Then modify your lilo.conf to boot using the new kernel, such as in lilo.conf to add a few lines to increase the startup item on the new support LVS:

Image = / boot / vmlinuz-lvs label = lvs read-only root = / dev / sda1

Note: If you use GRUB to start booting, do your own corresponding modifications to increase the startup item on the new Kernel that supports LVS.

Restart Linux, select the LVS item to enter Linux.

Install IPVSADM

If you start it normally, you will start installing the IP virtual server software IPvsadm. Because we use RH, we download directly to the RPM package. RPM package from the address: http://www.linuxvirtualserver.org/software/kernel-2.4/ipvsadm-1.21-7.src.rpm

Use the following command to install IPvsadm:

Rpmbuild --Rebuild IPvsadm-1.21-7.src.rpm rpm -ivh /usr/src/redhat/rpms/i386/ipvsadm-1.21-7.i386.rpm

At this point, the installation of the LVS is half complete. That is, the current Linux has already had the ability to implement LVS, and the next question is to build a group of Clusters if using LVS. To implement a group of Clusters, we must use the IPvSADM tool to configure, and we need to know some basic LVS knowledge before we start using IPvsadm, especially the three main points: LVS structure, LVS three Bacing forwarding, eight scheduling algorithms of LVS. Only after this knowledge is known, we can use IPvSADM to configure it. The following is a brief introduction to the three points of LVS:

1. LVS structure

The Cluster of the LVS mode can be divided into two parts: the front-end load balancer (called Director) and the backend real server (called Real Server). The Director at the front end of the Cluster will schedule requests from the outside to the rear end of the Cluster different. Real Server is responsible for truly providing a variety of application services, such as Web, FTP, Mail and other services. The number of Real Server can be increased, reduced according to the actual needs.

2. Three packets of LVS

LVS provides three pack-forwarding methods: NAT (network address map), IP tunneling (IP tunnel), Direct Routing (direct routing). Different forwarding modes determine the network structure of different clusters, the following, the three forwarding methods are each interpreted:

NAT (Network Address Map)

NAT way can support any operating system, as well as private networks, and only one Internet IP address, but the performance of the entire system is restricted. Because the execution NAT needs to rewrite the package, there is a certain delay; in addition, most applications have 80% of the data to flow from the server to the client, that is, the user's request is very short, and the server is very large, balancing the load A large pressure is formed, it has become a new bottleneck. IP tunneling (IP tunnel)

Director assigns requests to different REAL Server. Real server processes the request directly to the user so that the Director load balancer only handles half of the client and the server. IP tunneling technology greatly improves the Director's scheduling processing capability, and also greatly improves the maximum number of nodes that the system is accommodated, and can exceed 100 nodes. Real Server can run on any LAN or WAN, which means that geographic distribution is allowed, which is important in disaster recovery. The server must have a formal IP address to communicate directly with the client, and all servers must support IP tunnel protocols.

Direct Routing (direct routing)

Similar to IP tunneling, the load balancer only handle half of the connection to avoid new performance bottlenecks, which also increase the scalability of the system. Direct Routing has no IP package overhead compared to IP tunneling, but because all servers must be in a physical network segment due to the physical layer (modifying the MAC address) technology.

3. Eight scheduling algorithms of LVS

LVS has achieved the following eight scheduling algorithms:

1. Round-Robin Scheduling 2. Weighted Round-Robin Scheduling 3. Minimum Connection Scheduling 4. Weighted Least-Connection Scheduling 5. Locality-based Least Connections Scheduling 6. Local-based Least Connections With Replication Scheduling 7. Destination Hashing Scheduling 8. Source Added Scheduling 8. Source address Source Hashing Scheduling

Note: If you want to know about the technical details of the above points, LVS's home page query. The homepage of LVS is:

http://www.linuxvirtualserver.org/ http://www.linux-vs.org/

After understanding the three points of LVS, let's configure a Cluster using the Direct Routing package forward, weighted minimum connection scheduling algorithm.

We know that the Direct Routing package forwarding is to send the request to the Real Server by rewriting the MAC address of the request message. The Director machine of the front desk only needs to receive and scheduling the outside world without the need to returns the feedback results of these requests. Director machines and REAL Server have a network card to connect on the same physical network segment. So we give the following network topology:

The following configuration is required on the Director machine: set the IP: 192.168.2.1 of this machine and then execute the following command: ifconfig Lo: 0 192.168.2.255.255 Broadcast 192.168.255 Up Route Add-Host 192.168.2.254 Dev LO: 0 Ech / IPv4 / PROC / SYS / NET / IPV4 / IP_FORWARD ECHO 1> / Proc / Sys / Net / IPv4 / Conf / All / Hiddenipvsadm -c ipvsadm -a -t 192.168.254:80 -s WLC ipvsadm -a -t 192.168.2.254:80 -r 192.168.2.2 -g ipvsadm -a -t 192.168.2.254:80 -r 192.168.2.3 -g ... ipvsadm -a -t 192.168.254:21 -s WLC ipvsadm - A -T 192.168.2.254:21 -R 192.168.2.2 -g ipvsadm -a -t 192.168.2.254:21 -r 192.168.2.3 -g ......

The following configuration is required on the Real Server machine: for the first REAL Server (RS1), set the IP: 192.168.2.2 of this machine and then execute the following command: ifconfig LO: 0 192.168.2.254 Netmask 255.255.255.255 Broadcast 192.168.254 Up Route add -host 192.168.2.254 dev LO: 0

For other REAL Server: RS2, RS3, RS4 ..., do a phase class setting.

After completing the above settings, all access to the 80-port 192.168.254 will be allocated to the rear Real Server through the Director machine, while the results of Real Server will be directly refunded to the customer. At this point, we have completed an example of a Cluster. Through this example, I believe you can easily use Linux to set up a set of Cluster. In fact, after the Cluster is set here, it does not meet the requirements of formal application. There are still some problems in practical applications that need to be solved. For example, to install the monitoring software, monitor the operation of the cluster, you must find REAL Server's failure and adjust the corresponding adjustment Real SERVER list. There are also problems such as data consistency of the background Real Server node. These have been well resolved in some commercial Cluster software products, and the network also has some non-commercial software. For example, Mon is such a system resource monitor, which can monitor network service availability, server problems, etc., the most important thing is MON provides a framework that users can define and extensions themselves. See other articles, please refer to other articles.

转载请注明原文地址:https://www.9cbs.com/read-103335.html

New Post(0)