Linux Advanced Skills: heartbeat + lvs (1) and heartbeatlvs

Source: Internet
Author: User

Linux Advanced Skills: heartbeat + lvs (1) and heartbeatlvs


1. Introduction to heartbeat:

The Heartbeat project is an integral part of the Linux-HA project, which implements a high-availability cluster system. Heartbeat service and cluster communication are two key components of a highly available cluster. In the heartbeat project, the Heartbeat module implements these two functions.

This cluster solution is built using third-party software, which is simpler than the built-in cluster software of redhat, but it is very convenient to build. It is also a fast solution.

The high-availability cluster of heartbeat adopts udp protocol and serial port communication, and heartbeat plug-in technology realizes serial port, multicast, broadcast, and multicast communication between clusters. The Heartbeat software is installed on two servers at the same time to monitor the system status, coordinate the work of the master and slave servers, and maintain the system availability. It can detect faults in system software and hardware at the server application level, and timely isolate and recover errors; through system monitoring, service monitoring, automatic IP migration, and other technologies, we can ensure the continuous high availability of important services in a simple and economical manner without spof throughout the application. Heartbeat uses the virtual IP address ing technology to implement the function of transparent switching between master and slave servers to the client.

However, a single heartbeat cannot provide robust services, so we use lvs in the background for load balancing.


2. LVS Introduction

LVSYesLinux Virtual ServerWhich meansLinux Virtual ServerIs a virtual server cluster system. Founded by Dr. Zhang Wenyu.

IPVS

Speaking of lvs, we should mention ipvs. IPVS is the core software of The LVS cluster system. Its main function is to install it on Load Balancer, forward requests sent to the Virtual IP address to the Real Server. IPVS has three load balancing mechanisms. The IP Tunneling mechanism is used here:
? Virtual Server via NAT
? Virtual Server via IP Tunneling
? Virtual Server via Direct Routing

This experiment uses the last direct connection method.
Lvs scheduling algorithms are very important and you must be familiar with them. Have a detailed explanation on the official website: http://zh.linuxvirtualserver.org/
There are 10 Load Scheduling Algorithms for IPVS:

Round Robin)
Weighted Round call (Weighted Round Robin)
Least Link (Least Connections)
Weighted Least Connections)
Locality-Based Least Connections)
Locality-Based Least Connections with Replication)
Destination Hashing)
Source Hashing)
Shortest Expected Delay)
No Queue waiting (Never Queue)

Note: We use a simple call method.

3. ldirectord introduction:

Ldirectord works with lvs as a health check mechanism, or the Server Load balancer still has no detection function after the node fails.



The basic concepts of heardbeat, lvs, and ldirectord are introduced above. It is better to set up a service to show you the effect.

4. Set up the RHEL6.5 + LVS + Linux-HA + Ldirectord Service (provides http and ftp services as an example)

Note:

1. System: redhat6.5;
2. nodes: a total of four virtual machines are used as nodes. Two of them are installed with heartbeat and lvs, and the other two nodes only provide apache and vsftpd services;
3. The resolution between the four nodes must be well done;
4. Firewall is disabled and time synchronization is performed. The system versions of the four hosts should be the same.

As shown in the experiment environment, the first console is my real machine, the other four are the four nodes of the experiment, the first two install heartbeat and lvs, and the last two consoles provide apache and vsftpd services. Next we will configure it in parts.


1. Install heartbeat:

This is a third-party software, not a redhat package, so you need to download it yourself:, respectively:

Heartbeat-3.0.4-2.el6.x86_64.rpm
Heartbeat-devel-3.0.4-2.el6.x86_64.rpm
Heartbeat-libs-3.0.4-2.el6.x86_64.rpm

I have a vsftpd service on my local machine. You can also find it at http://rpm.pbone.net.

Both nodes should have these three packages. Then install them in a custom location:



If the installation is not successful, you must reset your yum Source:
Vim/etc/yum. repos. d/yum. repo


This is the three configuration files of heartbeat:

, Ha. cf Main configuration file
Haresources Resource configuration file
Authkeys Authentication information

The configuration file does not exist by default. We have to copy one from other places:



Vim ha. cf:


Keepalive 2
Set the heartbeat interval to 2 seconds.
Warntime 10
The waiting time before the "late heartbeat" Warning is sent in the log, measured in seconds.
Deadtime 30
After 30 seconds, the node is declared dead.
Initdead 120
In some configurations, it takes some time for the Network to work properly after restart. This separate "deadtime" option can handle this situation. The value should be at least twice the usual deadtime.
Udpport 694
Use port 694 for communication between bcast and ucast. This is the default port number that is officially registered in IANA.





Automatic failback after reply by default:



There are two nodes to install heartbeat:



Used to test whether the node network is connected:





The above is the modification of the ha. cf configuration file, and then we will come to the authkeys file:



Modify the object ACL:



Finally, let's modify haresources. We need to add an apache service to it, but we need to give it a virtual ip address (this ip address must not be occupied by others ), let these two nodes be used as their theory searches.



The httpdservice is installed on both sides for testing. In order to partition, we write different content in their index.html (in fact, the content of both is the same in the production environment, because we do load balancing)

After completing the preceding content, enable the heartbeat service on both sides:


Then we can test the effect through firefox:



Then let's close the current node heartbeat and find another node automatically takes over:





Let's enable the heartbeat of the node just now, because it is the master node (server101.example.com), so it is taken over again:





Summary:

In this way, Server Load balancer is effective, but this is just a pure heartbeat. We have not yet combined it with lvs, and our functions are not perfect, in the next post, we will gradually combine the two. The next post will first let everyone feel the effect of lvs when used separately, and finally combine the two.







Heartbeat dual-host hot standby service setup on linux I 'd like to ask if heartbeat comes with LINUX

Heartbeat is only carried by suse, rh, and centos. You can see it in the cluster suite, and there is it in the CD. What's more, we recommend you find it online. It's useless to use images.

LVS + heartbeat Problems

What do you mean by this question? What do you want?

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.