Set up a Linux (2.6.14 kernel)-based server cluster

Source: Internet
Author: User

What is a cluster?

A cluster is a group of independent computer systems that constitute a loosely coupled multi-processor system. They communicate with each other through a network. Applications can transmit messages through the network shared memory to implement distributed computers. Clusters work in a way similar to collaboration between people.

Vs-nat cluster is the simplest cluster. Its structure is similar to the linux transparent proxy server.

This is a picture downloaded from the network, which is a typical nat structure. This structure can be used for simple tests. Is a linux host, which is responsible for balancing traffic. It is usually called a linux virtual server. RS1 and RS2 are the actual servers. The virtual server does not process service requests. All requests are processed by the actual server. The nat structure is very simple. You can modify the network structure according to the actual situation.

Configuration process on LVS

Server Load balancer is a kernel-level function module. Generally, it does not provide Server Load balancer functions in the release. Therefore, we need to re-compile the kernel to support the load balancing function. We chose the latest kernel version 2.6.14. The following describes how to compile and make the new kernel work correctly.

Download the module-init-tools-3.1.tar.bz2 code package from www.kernel.org.

It can be seen from the name that this is a module-related tool. We load the Server Load balancer as a module into the kernel.

Use tar-jzvf to decompress the package, and then follow the steps in README to install the package.

./configure –prefix=/

make moveold

make

make install

The module-init-tools installation is complete.

The process for installing kernel 2.6.14 is as follows:

Download the source code package linux-2.6.14.2.tar.bz2 from www.kernel.orgto the/usr/src/directory.

Decompress with tar-jxvf linux-2.6.14.2.tar.bz2 command

Decompress to generate a linux-2.6.14 directory

Rename this directory to music linux-2.6.14 linux

Then run cd/usr/src/linux

Make menuconfig is a Graphical Kernel configuration tool. You can use this tool to select the features of the new kernel. It is not described in detail here. You only need to select exit.

Make: This is the command for compiling the kernel. It takes a long time to execute this command. You have to wait patiently for the command to run :-)

Make modules

Make modules_install is of course the installation module.

So far, a new kernel of your own will be compiled, and some work needs to be done to make the new kernel work smoothly.

When the kernel is compiled, the new kernel is located in/usr/src/linux/arch/i386/boot, and bzImage is your new kernel.
Cp bzImage/boot: copy the new kernel to the startup partition of the system.

Next, modify grub. If you install lilo, the method is basically the same)

Vi/etc/grub. conf

Append the following content

Title linux virtue server

Root (hd0, 0)

Kernel/boot/bzImage root =/dev/hda1

Save and exit.

When Reboot is restarted, a linux guest ue server is added during selection.

Select this option to use your new kernel.

Next we will introduce ipvsadm

Ipvsadm is a tool for configuring the kernel traffic allocation policy. It allows us to choose the policy to forward data packets.

The simplest strategy is round robin. It's like playing a card. External requests are sent to the actual server in turn.

It is too easy to install. It is described in README :)

After installation, run the following command:

Echo 1>/proc/sys/net/ipv4/ip_forward

./Ipvsadm-C

./Ipvsadm-A-t 192.168.88.23: 80-s rr

./Ipvsadm-a-t 192.168.88.23: 80-r 10.0.0.2: 80-m

./Ipvsadm-a-t 192.168.88.23: 80-r 10.0.0.3: 80-m

./Ipvsadm-a-t 192.168.88.23: 80-r 10.0.0.4: 80-m

// The first sentence means that the linux host supports packet forwarding.

// The second sentence indicates clearing the kernel virtual list.

// The third sentence is to add a virtual service, which provides port 80 of 192.168.88.23.

// The-s parameter specifies the scheduling method rr as the round robin

// Add an actual server to the preceding virtual service. The ip address is 10.0.0.2 and the port is 80.

// The-m parameter specifies the nat mode.

// I will not need to talk about it next :-)

The above is the code I used for testing. Briefly describe its structure: a server is used for load balancing. It has two NICs and one ip address is 192.168.88.23, which is the external ip address of the entire cluster. another ip address is 10.0.0.1. this ip Address

Of course, the role is to connect to the actual server. J. I used three machines as the actual server during the test. The ip address is 10.0.0.2.

Both 10.0.0.3 and 10.0.0.3 have their gateways set to 10.0.0.1, and the system is redhat9.0, which is used by apache.

If you have a public ip address, set the NIC with the original ip address 192.168.88.23 to your public ip address.

About iptables

I got a new version of iptables-1.3.4. After decompression, follow the instructions in INSTALL and execute

./iptables –t nat –A POSTROUTING –s 10.0.0.0/24 –d 0.0.0.0/0 -j SNAT –to 192.168.88.23

Test

The default home page is located

/Var/www/html/. Then execute service httpd start. On 192.168.88.21, browse 192.168.88.23 and later. This is a browser problem, not a configuration error. It can be seen that different home pages indicate that the three servers can work normally, and the cluster can work.

Problem

What if the machine responsible for traffic distribution is paralyzed or the actual server has a problem? How can this problem be solved?

The first problem is hot backup. This is also the method used by most clusters. Heatbeat software required

The second problem is to configure the keepalive software on the server Load balancer instance.

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.