A detailed description of how to properly build a Linux server cluster

Source: Internet
Author: User

What is a cluster?

Cluster is a set of independent computer systems that form a loosely coupled multiprocessor system that communicates between processes over a network. Applications can deliver messages over network shared memory for distributed computers. Clusters work in a way similar to people's collaborative work.

The Vs-nat cluster is one of the simplest clusters. His structure is similar to the Linux transparent proxy server.

This is a picture downloaded from the network, which is a typical NAT structure. This type of structure can be used for simple testing. The LVS identifier is a Linux host that is responsible for balancing traffic. It is often called a Linux virtual server. The RS1 identity and the RS2 identity are the actual servers. The virtual server does not process service requests, and all requests are handled by the actual server. NAT structure is very simple, can modify the network structure according to the actual situation.

LVS the configuration process on the

Load balancing is a functional module at the kernel level and generally does not provide load balancing functionality on the release version. So we need to recompile the kernel to support the load balancing function. We chose the latest version of kernel 2.6.14. The following is the process of compiling and making the new kernel work correctly.

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

As you can see from the name, this is a module-related tool. We load the load balancer into the kernel as a module.

Unzip with TAR–JZVF, then follow the steps in the Readme to install.

./configure–prefix=/

Make Moveold

Make

Make install

The Module-init-tools installation is complete at this time.

Install below 2.6.14 the process of the kernel

Download source code packages from www.kernel.org linux-2.6.14.2.tar.bz2 to/usr/src/directory

Decompression with TAR–JXVF linux-2.6.14.2.tar.bz2 command

Generate linux-2.6.14 Directory after decompression

Rename this directory MV linux-2.6.14 Linux

Then execute Cd/usr/src/linux

Make Menuconfig This is a graphical kernel configuration tool. You can use this tool to select the functionality of the new kernel. This is not explained in detail, just choose Exit.

Make this is the command to compile the kernel. This command takes a long time to execute, and you have to wait patiently:-)

Make modules this is the command time to compile the kernel module it won't take long to see your CPU speed.

Make Modules_install is, of course, the installation module.

Now a new kernel of your own has been compiled, and some work will be done to make the new kernel work well.

When the kernel is compiled, the new kernel is located under/usr/src/linux/arch/i386/boot, where the bzimage is your new kernel

CP bzimage/boot Copy the new kernel to the boot partition of the system

Next Modify GRUB (it doesn't matter if you have 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

Then save the exit.

Reboot Restart will find that there is a more Linux virtue server in the selection

Choose this option to use your new kernel.

Next Introduction Ipvsadm

Ipvsadm is a tool for configuring kernel traffic allocation policies. It allows us to choose what strategy to use to forward packets.

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

Its installation is too simple, in the Readme is explained:)

After installation, execute 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 means emptying the kernel virtual list

The third sentence means to join a virtual service, which is a 192.168.88.23 80 port.

-s parameter specifies the scheduling mode RR for round robin

The meaning of the sentence is to add an actual server for the above virtual service, IP 10.0.0.2, Port 80

-m parameter specifies NAT mode

The next thing I said:-)

The above is the code I used to test. A simple description of its structure: a machine to do load balancing, it has two network cards, 1 blocks of IP 192.168.88.23, this IP is the entire cluster external IP. The other IP is 10.0.0.1. This IP

The role of course is to connect the actual server, J I test with three machines to do the actual server, IP for 10.0.0.2

10.0.0.3 and 10.0.0.3, their gateways are set to 10.0.0.1, the system is redhat9.0, all by Apache service.

If you have a public IP, then the original IP 192.168.88.23 network card is set to your public IP on the line.

about the iptables

I have a new version of iptables-1.3.4. After decompression, follow the instructions in install to 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

Different index.html were arranged on the 10.0.0.2,10.0.0.3.10.0.0.4. The default home location on the Redhat9

/var/www/html/. Then the service httpd start is done. Browse 192.168.88.23 on 192.168.88.21, One of the index.html will appear. Here you need to note the browser settings, you need to delete the temporary files after refreshing to see the other index.html. This is a browser issue, not a configuration error. Can see different Main page description 3 actual servers are working, and the cluster will work.

A detailed description of how to properly build a Linux server cluster

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.