CentOS6.6 install heartbeat for High Availability

Source: Internet
Author: User
Tags sha1 hash sha1 hash algorithm

CentOS6.6 install heartbeat for High Availability

I recently learned about the High Availability Technology in linux under the guidance of a teacher, using the heartbeat software to achieve high availability of Server clusters. Below I will record the problems and some personal opinions I encountered during my studies and tests, for the reference of the majority of bloggers. My level may not be enough. Please try again.

The first problem I encountered was that I did an experiment on a virtual machine on ESXI of VMWARE. I did the experiment all the way through the teacher's steps, but the result was split-brain, then I cleared the configuration and re-configured it again. As a result, split-brain occurs. So we used VMware workstation to install the virtual machine on the local machine to perform this experiment. The experiment steps are the same, but the experiment was successful at one time. It can be seen that there is a problem with ESXI. The specific problem has not been found yet ..... QAQ, the level is limited.

Then it was intended to use CentOS7 to do this experiment, but in CentOS7 above Life and Death cannot find yum install heartbeat package, after installing the epel-release-7.5 can still not be found, and later intends to use rpm package installation, the result shows that dozens of rpm dependent packages need to be installed, which is difficult to implement. Therefore, the second step is to use centos6.6 to complete this experiment. I believe that this experiment can also be performed on centos7. Maybe I didn't find the correct method.

All right, you are tired of reading this nonsense, so I 'd like to give you some advice.

First, the topology is as follows:

The two servers are used for high availability. The virtual IP Address type is 10.6.0.187. The heartbeat line is used to determine whether the other server is alive.

Next we will use heartbeat for the HA cluster and use the nginx service as the corresponding HA service.

Test preparation:

Both machines are centos6.6, And the eth0 ip address of the NIC is as follows:

Test1 10.6.0.188

Test2 10.6.0.189

The two eth1 ip addresses are as follows:

Test1 10.6.100.188

Test2 10.6.100.189

The following operations are performed on both machines:

1. Set the hostname to test1 and test2, respectively.

2. Disable the firewall iptables-F;

Disable selinux: setenforce 0

3. Add the following content to vi/etc/hosts:

10.6.0.188 test1

10.6.0.189 test2

4. Install the epel extension Source:

Yum-y install epel-release

5. Install heartbeat/libnet on both machines

Yum install-y heartbeat nginx

6. Master (test1) Configuration

cd /usr/share/doc/heartbeat-3 .0.4/ cp authkeysha.cfharesources /etc/ha .d/ cd /etc/ha .d vi authkeys # Open the following two items: There are three authentication methods to choose from. The first is CRC cyclic redundancy check, the second is SHA1 hash algorithm, and the third is MD3 hash algorithm, their passwords can be set at will, but they must be consistent on both sides. auth3 md5Hello! chmod 600authkeys # Authorize the authentication file to 600 vi haresources # Add the following statement test110.6.0.187 /24/eth0 :0nginx # Set the virtual IP address and the corresponding interface, and specify to start the NGINX service when starting the virtual IP address. The NGINX service here must be directly in/etc/init. d/directory. vi ha.cf # Change to the following content: debugfile /var/log/ha-debug # Set the debug file directory logfile /var/log/ha-log # Set the log file directory logfacilitylocal0 keepalive2 # Set the check interval to 2 s deadtime30 # Set the death time to 30 s warntime10 # Set the alarm time to 10 s (if the other party does not receive a response within 10 s, the alarm will be triggered) initdead60 # Set the initialization time to 60 s udpport694 # Start the udp694 listening port (this port can be modified) ucasteth110.6.100.189 # Set the listener's heartbeat line interface and the IP address of the corresponding peer interface auto_failbackon # Start the preemption mode (the master node automatically switches to the slave node after it is restarted) nodetest1 # Specify two nodes nodetest2 ping 10.6.100.1 # Specify a third-party arbitration Node respawnhacluster /usr/lib/heartbeat/ipfail # Use this script to check whether the other party is still alive (ICMP packet detection is used)

7. Copy the three configurations on the master to the top:

Cd/etc/ha. d/

Scp authkeys ha. cf haresources test2:/etc/ha. d/

8. Edit ha. cf from top (aming1)

Vi/etc/ha. d/ha. cf // you only need to change the location

Change ucast eth1 10.6.100.189 to ucast eth1 10.6.100.188.

9. Start heartbeat:

First Master, then slave

Service heartbeat start

After the master is started, an eth0: 0 is displayed on the master node, and the eth0: 0 is not started on the slave node.

You can view the debug log and software log to check whether the startup is normal:


NGINX is automatically started on the master node, and the eth0: 0 interface is not started on the slave node.

So I expanded it. After the heartbeat line interface on the master node was down, the slave node started the virtual IP interface because it could not detect that the master node was still alive, takes over from the master. When the master heartbeat line interface is up, the slave node actively returns the virtual IP address to the master node and becomes the slave node.

Then, after I put the external interface on the master node down, the slave node failed to implement high availability because it detected that the heartbeat interface was still normal and thought that the master node was still alive. After the master puts the external interface up, you need to restart the heartbeat service to take over the work from the slave.

From this, we can see that the heartbeat line is crucial. When the heartbeat line goes down, it may lead to split-brain behavior (that is, the master and slave are both in control of the virtual IP address ), in the actual environment, it is best to redundant the heartbeat line and use Ethernet port bundling to ensure the robustness of the heartbeat line.

At the same time, if the main external interface is down, but the heartbeat line is not down, the slave node will not be able to detect the master node and thus cannot achieve high availability.

The above points are only my comments. You are welcome to propose better solutions and ideas.

This article is from the "Lemon" blog, please be sure to keep this source http://xianglinhu.blog.51cto.com/5787032/1658633

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.