Definition of Heartbeat
The Heartbeat project is an integral part of the LINUX-HA project and the most successful example of the current open source HA project, Linux-ha is High-availability Linux, the goal of this open source project is to: through the joint efforts of Community developers, Provides a clustering solution that enhances Linux reliability (reliability), availability (availability), and serviceability (serviceability) (RAS), 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.
Ii. versions and components of heartbeat
Description: Heartbeat has three versions of Heartbeat v1.x,heartbeat v2.x,heartbeat v3.x respectively. The composition of the Heartbeat v1.x and Heartbeat v2.x versions is simple, all modules are concentrated in Heartbeat, and after the V3 version, the entire Heartbeat project is split and divided into different projects to be developed separately.
Components for 1.Heartbeat v1.x and v2.x
Heartbeat: Inter-node Communication detection module
HA-LOGD: Cluster Event Log service
CCM (Consensus Cluster Membership): Cluster member consistency management module
LRM (local Resource manager): On-Premises Resource management module
Stonith Daemon: Detach or restart a problematic node from a clustered environment
CRM (Cluster resource Management): Cluster resource management module
Cluster Policy engine: Cluster strategy engines
Cluster transition Engine: Cluster transfer engines (also called Policy execution engines)
Heartbeat v1.x differs from Heartbeat v2.x: A new cluster resource Manager CRM is added in Heartbeat v2.x, and cluster Explorer in Heartbeat v1.x is haresource,heartbeat V2.x retains haresource in order to be compatible with v1.x, but adds a more powerful CRM Resource manager at the same time. CRM Management method has, one is based on the command line CRMSH, one is based on the graphical interface Hb_gui.
Components for 2.Heartbeat v3.x
Heartbeat: The original message communication layer is independent of the Heartbeat project, and the new Heartbeat is only responsible for maintaining the information of the nodes of the cluster and their prior communication.
Cluster Glue: Equivalent to an intermediate layer, which is used to correlate heartbeat and pacemaker, consisting mainly of 2 parts, namely LRM and Stonith.
Resource Agent: A collection of scripts used to control service start-stop and monitor service status, which will be called by LRM for various resources to start, stop, monitor and so on.
Pacemaker: Cluster Resource Manager (Cluster Explorer, referred to as CRM), is used to manage the entire HA control center, the client through the Pacemaker to configure the management to monitor the entire cluster.
Jobs: HA is implemented based on Heartbeat v2 CRM with lamp combination.
1. Address Planning
node1.test.com 192.168.77.101 node2.test.com 192.168.77.30 VIP 192.168.77.200
2. Host name resolution
[[email protected] ~]# uname -n node1.test.com [[email protected] ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain Localhost6 localhost6.localdomain6 192.168.77.101 node1.test.com node1 192.168.77.130 node2.test.com node2 [[email Protected] ~]# uname -n node2.test.com [[email protected] ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.77.101 node1.test.com node1 192.168.77.130 Node2.test.com node2
3. Configure mutual trust
[Email protected] ~]# ssh-keygen-t rsa-f ~/.ssh/id_rsa-p "[[email protected] ~]# ssh-copy-id-i. ssh/id_rsa.pub [Emai l protected] [[email protected] ~]# ssh-keygen-t rsa-f ~/.ssh/id_rsa-p ' [[email protected] ~]# Ssh-copy-id- I. ssh/id_rsa.pub [EMAIL protected]
4, Configuration Time synchronization
# yum-y Install ntpdate # ntpdate time.windows.com
5. Install lamp
[[email protected] ~]# Yum install http mysql-server php php-mysql
6. Install Heartbeat related software package
[[email protected] ~]# Yum install net-snmp-libs libnet pyxml[[email protected] ~]# RPM-IVH heartbeat-2.1.4-12.el6.x86_64 . RPM heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm
7, Configuration Heartbeat
Copy Ha.cf,authkeys,haresources to/ETC/HA.D
[Email protected] ~]# Cp/usr/share/doc/heartbeat-3.0.4/{ha.cf,authkeys,haresources}/etc/ha.d/
Edit Authkeys File
[email protected] ~]# OpenSSL Rand-hex 8 >> authkeys #生成密钥追加到authkeys文件中 [[email protected] ~]# VI authkeys #修改为以下配 Auth 2#1 crc#2 SHA1 hi! #3 MD5 hello!2 SHA1 d0071be771be703c, using SHA1 encryption
Edit the HA.CF master configuration file
[Email protected] ~]# grep-v ' ^# ' ha.cf |sed '/^$/d ' logfacility local0 mcast eth1 225.0.0.1 694 1 0 #修改心跳信息 Broadcast Mode | Multicast auto_failback on node node1.test.com #配置集群中的节点数 node node2.test.com #配置集群中的节点数
Edit Haresources configuration file
[Email protected] ~]# grep-v "#" haresourcesnode1.test.com 192.168.77.200/24/eth1 httpd
Copy Profile Guide Node2
[Email protected] ~]# Scp/etc/ha.d/{ha.cf,haresources,authkeys} [email protected]:/etc/ha.d/
V. Provide HTTPD services to nodes
Edit HTML
[[email protected] ~]# echo
Start httpd
[[Email protected] ~]# service httpd start
Explore Node1
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/D8/wKioL1YrktuzoSaLAAC_Nl02afM037.jpg "title=" Qq20151024221718.jpg "alt=" Wkiol1yrktuzosalaac_nl02afm037.jpg "/>
Node2 Close Iptabels
[[email protected] ~]# Getenforcedisabled[[email protected] ~]# service iptables stopiptables: Set the chain to policy Accept:nat mangle F Ilter [OK]iptables: Clear firewall rule: [OK]iptables: Uninstalling module: Determine [Email protected] ~]#
Accessing the Node2 node
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/D8/wKioL1Yrk8fDzG9iAACvyIUwVDs862.jpg "title=" 123. JPG "alt=" wkiol1yrk8fdzg9iaacvyiuwvds862.jpg "/>
Start the Heartbeat service
[Email protected] ~]#/etc/init.d/heartbeat start starting high-availability Services:INFO:Resource is stopped Done.
View VIP
[[Email protected] ~]# IP addreth1: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast State up Qlen 1000 Link/ether 00:0c:29:c7:14:97 BRD ff:ff:ff:ff:ff:ff inet 192.168.77.101/24 BRD 192.168.0.255 scope Global eth1 inet 192.168.77.200/24 Scope Global Eth1
See if the HTTPD service is heartbeat taken over [[email protected] ~]# netstat-tnlpu |grep httpd2 TCP 0 0::: 80 :::* LISTEN 2140/httpd
Browser testing
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/74/DB/wKiom1YrmxeDgU3MAACFFhcvWCY065.jpg "title=" Node1.jpg "alt=" Wkiom1yrmxedgu3maacffhcvwcy065.jpg "/>
Stop NODE1,HTTPD after testing
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/74/D8/wKioL1Yrm4HSuS9LAACbbhshcd8637.jpg "title=" Node2.jpg "alt=" Wkiol1yrm4hsus9laacbbhshcd8637.jpg "/>
With lamp combination, HA is implemented based on Heartbeat v2 CRM