Heartbeat Introduction
The Heartbeat project is an integral part of the LINUX-HA project, which implements a highly available cluster system. Heartbeat service and cluster communication are two key components of a highly available cluster, and in the Heartbeat project, these two functions are implemented by the Heartbeat module.
Heartbeat structure Diagram
650) this.width=650; "Src=" http://img.blog.csdn.net/20170731120145362?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqva2fpcnvpmtiz/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "/>
The base layer: (Heartbeat transfer layer) runs on each node and is sent to each alternate node by means of a multicast. This protocol works on 694 ports of UDP.
CRM: (cluster resource manager) relies on the heartbeat layer and can be uploaded and information to install with each node.
LRM: (local resource manager) is scheduled by the CRM, implement CRM decision, find Ra to execute.
RA: (resource agent) is able to accept the scheduling of CRM, which is used to implement resource scheduling and configuration on one node, usually script. Script must accept {Start|stop|restart|status}
How CRM Works
In the many CRM will choose a CRM as the administrator, responsible for scheduling the use of the standby server as the primary server.
Heartbeat common software for each layer
1. Information layer: A.heartbeat v1,v2,v3 b.corosync 2. Crm:a.heartbeat v1: Configuration Interface (configuration file) b.heartbeat V2:crm (command) c.heartbeat v3:heartbeat+pacemaker+gluster-glue (sticky and extruded) D.P Acemake 3. Ra:a.heartbeat Legacy:heartbeat's traditional type B.OCF: Open source cluster framework
Prevent brain fissure
Node level: The power supply of the few clusters is cut off in the form of a small number of subordinate majority.
Resource level: Shields a few sets of groups from accessing public resources.
Working mode of the cluster
N-M model: n>m run m service on N nodes, fail on M service, transfer service to one of N-M nodes, in this cluster mode, at least 3 hosts N-n model: Run n services on N nodes, run a service on each node, When one of the nodes fails, the service is transferred to another node. At least two hosts. A/A Model: This model is a two-master mode, the two hosts run two main services respectively, two primary services correspond to different IPs, and when one fails, it will be transferred to another one. 123456123456
How resources are transferred
Rgmanager: (failover domain) refers to the transfer of Pacemaker: Resource constrained resource stickiness: Refers to resource constraints, which are more likely to run on that node, depending on the stickiness. 1. Location constraint: The resource is more inclined to run the node INF: Infinity, the resource must be running on this node-inf: Infinity, the SLR may have left this node 2. Order constraints: Define the resource start order and closing order 3. Sort constraint: Two resources willing to be together INF: expressing willingness to-inf: expressing reluctance to use sequential and sort constraints often
Resource type
Primitive,native: Master resource, can only run on one node
Group: Groups Resources
Clone: Cloning resources, can run on multiple nodes, need to define two parameters (total number of clones, maximum number of clones per node)
Master/slave: Master-Slave resources
How resources are not processed in the cluster
STOP: Stop service
Ignore: Ignore is not a cluster member, continue to run.
Freeze: Freezes, does not understand the new request.
Suicide:kill Sever
Heartbeat V1 for high availability of web resources
1. yum installation heartbeat [[email protected] ~]# wget http:// Mirrors.sohu.com/fedora-epel/6/i386/epel-release-6-8.noarch.rpm [[email protected] ~]# rpm -ivh epel-release-6-8.noarch.rpm [[email protected] ~]# yum install heartbeat* 2. configuration file/etc/ha.d/directory [[email protected] ~]# cp /usr/share/doc/heartbeat-3.0.4/{ha.cf,authkeys,haresources } /etc/ha.d/ [[email protected] ~]# chmod 600 /etc/ha.d/ Authkeys 3. authkeys configuration Files formats: auto {1,2,3} 1 crc 2 sha1 Password 3 md5 password 4. HA.CF Common Profiles logfile /var/log/ha-log //Log Files keepalive time //How long does a heartbeat test deadtime 30 How long does the //not detect heartbeat, take over resources warntime 10 How long does the //not detect heartbeat, write log initdead 120 //after the system restarts or starts, How long after the network works again dpport 694 baud 19200 //set serial communication baud rate bcast eth0 //setting up broadcast interfaces mcast eth0 225.0.0.1 694 1 0 //Multicast ucast eth0 ip //unicast auto_ After the failback on //master node is restored, Ability to cut back node Clone1 //Master Node host node clone2 //Alternate Node Host compression bz2 //Compression Transfer compression_threshold 2 //compression minimum limit in kilobytes 5. haresources Resource Profile format: First Type: Master node (nodel) vip|vip/mask/dev service name Second Type: Master node (Nodel) vip|vip/mask/dev filesystem::/dev/sad1::/hang at point service name eg:clone1 192.168.80.150 httpd
Test Results
650) this.width=650; "Src=" http://img.blog.csdn.net/20170731150820578?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqva2fpcnvpmtiz/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "/>
650) this.width=650; "Src=" http://img.blog.csdn.net/20170731151101597?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqva2fpcnvpmtiz/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "/>
turn off the heartbeat of the master node
650) this.width=650; "Src=" http://img.blog.csdn.net/20170731151306408?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqva2fpcnvpmtiz/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "/>
Configuring Web High availability using heartbeat V2
Configure Step 1. Install Heartbeat-gui on the basis of heartbeat V1 and install only 2 on the primary service. Add CRM on this line in profile HA.CF 3. Delete haresources file 4. /usr/lib64/heatbeat/ha_propagate can synchronize the configuration file to the other node. 5. Enable Hearbeat-gui [[email protected] ~]# Hb-gui &
Because the heartbeat V3 configuration is the same as the command and Corosync+pacemaker configuration, Heartbeat V3 is not configured here, and Corosync+pacemaker configuration is used in the next period.
Linux heartbeat enables high availability of servers