Ha High Availability Cluster

Source: Internet
Author: User

HA (high available) is highly available and is also known as a dual-machine hot standby for critical business. The simple understanding is that there are two machines A and B, the normal is a service, B standby idle, when a down or service outage, will switch to the B machine to continue to provide services. Commonly used high-availability open source software has heartbeat and keepalived, where keepalived has load-balanced functionality. The experiment uses heartbeat to do Ha,nginx service as the HA corresponding service.

Prepare both the machine master and slave, the system environment are 64-bit centos6.5, the network card eth0 IP is 192.168.137.101 and 192.168.137.110, and on both machines vim/etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain Localhost6 localhost6.localdomain6192.168.137.101 master192.168.137.110 slave off firewall, RPM-IVH '/http  www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm ' Install Epel extension source, yum Install-y heartbeat* libnet Nginx installation Heartbeat and Nginx service,

cd/usr/share/doc/heartbeat-3.0.4/on Master (master),

CP ha.cf Authkeys haresources/etc/ha.d/Copy these three files to/ETC/HA.D,

Cd/etc/ha.d/,

Vim Authkeys

Auth 3#1 crc#2 SHA1 hi!3 MD5 hello!

Here choose 3, middle term, 2 is the best, 1 is the worst,

Then CHOMD Authkeys

Vim Haresources

Add the Master 192.168.137.105/24/eth0:0 nginx//Here eth0:0 is a virtual network card, connect master and slave, also called VIP

First > HA.CF empty the file, and then

Vim HA.CF

Join

Debugfile/var/log/ha-debuglogfile/var/log/ha-loglogfacility local0keepalive 2deadtime 30warntime 10initdead 60udpport 694ucast eth0 192.168.137.110auto_failback onnode masternode slaveping 192.168.137.1respawn hacluster/usr /lib64/heartbeat/ipfail

Note here that the Ucast eth0 is from the IP, through the ping 192.168.137.1 gateway to determine whether the master-slave is dead, there is a little

Respawn Hacluster/usr/lib64/heartbeat/ipfail This is a 64-bit path, the 32-bit should be respawn hacluster/usr/lib/heartbeat/ipfail

SCP Authkeys ha.cf haresources slave:/etc/ha.d/If there is no SCP can be Yum install-y openssh* (both machines to install SCP), of course, can also use rsync.

On the Slave (from),

cd/etc/ha.d/

Vim HA.CF

Change Ucast eth0 192.168.137.110 to Ucast eth0 192.168.137.101


Test ha:

Service Heartbeat start Heartbeat, Guthrie starts again from sequence

Ifconfig or IP add to see if the eth0:0 virtual network card is more than

PS Aux|grep Nginx to see if our Lord has a startup Nginx service

Note: Only master on more than eth0:0 and nginx services, if from the above also more these services, then HA is not successful (just yum install nginx may start Nginx, can stop Nginx and heartbeat, And then start heartbeat)

Test 1
The Lord deliberately forbidden Ping
iptables-i input-p icmp-j DROP
Can be seen when the master can not ping the gateway, slave will immediately open eth0:0 and Nginx, of course, we can modify the index.html file under/usr/share/nginx/html/, the Lord's Echo "123master" > index.html, from the echo on the "321slave" > index.html, so you can enter the eth0:0 IP in the Web browser http://192.168.137.105/

To test which machine the Nginx works on.
Test 2
Lord stop Heartbeat service
Service Heartbeat Stop, the situation is similar to the case of Test 1.
test for brain fissure
The Lord and the Eth1 network card from the top, although master and slave network cards are down, but eth0:0 still in operation


This article is from the "10707334" blog, please be sure to keep this source http://10717334.blog.51cto.com/10707334/1719589

Ha High Availability 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.