Manage Heartbeat using CRM

Source: Internet
Author: User
Tags scp command

Manage Heartbeat using CRM

Heartbeat is an open-source Linux-based, widely used high-availability cluster system. It mainly includes two high-availability cluster components: Heartbeat service and resource manager. Its resource management method can be managed by using the haresource file method, or by using the CIB method. CIB-based cluster resources use xml format to save their resource configuration information. Resources Based on haresouce file management can be converted to CIB-based management. Its biggest advantage is that CIB management makes cluster management more convenient and easy to monitor. This document describes how to manage heartbeat using crm.

1. Description of related configuration files
### Node Information
# More/etc/hosts localhost. localdomain localhost

# Public ip orasrv1 orasrv2

# Private ip orasrv1-priv orasrv2-priv

### Configuration file information
# Cat/etc/ha. d/ha. cf ### ha. cf file
Keepalive 2
Deadtime 15
Warntime 30
Initdead 60
Udpport 694
Bcast eth0
Auto_failback off
Respawn hacluster/usr/lib64/heartbeat/ipfail
Crm respawn ### this item is used to define how to enable crm, or pacemaker (after heartbeat V3)

# CRM and Resources are not compatible. If CRM is defined in ha. cf, the HA service will not read the/etc/ha. d/haresources configuration file.
# The following message is displayed in the log file: This file is not used because crm is enabled.

# Cat/etc/ha. d/authkeys ### authkeys File
Auth 1
1 md5 74a6a503b5bec9373b22bb630608df41

# More/etc/ha. d/haresources ### resource file IPaddr: httpd

### Use ha_propagate to synchronize the configuration file. Note that the configuration file does not contain the haresource file.
### Ha_propagate uses the scp command based on equivalent ssh, and connects to the node and enables heartbeat auto-start using chkconfig
[Root @ orasrv1 heartbeat] #/usr/lib64/heartbeat/ha_propagate

Ii. Start the heartbeat Service
# Service heartbeat start ### Node 1
# Ssh orasrv2 'service heartbeat start' ### Node 2
# Netstat-nltp | grep 5560 ### view the mgmtd Port
Tcp 0 0 5560 * LISTEN 4128/mgmtd
# Ssh orasrv2 'netstat-nltp | grep 100'
Tcp 0 0 5560 * LISTEN 3434/mgmtd

### View heartbeat-related processes
# Ps-AHfww | grep heartbeat | grep-v grep
Root 5564 1 0 Nov11? 00:00:40 heartbeat: master control process.
Nobody 5567 5564 0 Nov11? 00:00:04 heartbeat: FIFO reader
Nobody 5568 5564 0 Nov11? 00:00:09 heartbeat: write: bcast eth0
Nobody 5569 5564 0 Nov11? 00:00:03 heartbeat: read: bcast eth0
Nobody 5570 5564 0 Nov11? 00:00:07 heartbeat: write: ping
Nobody 5571 5564 0 Nov11? 00:00:02 heartbeat: read: ping
496 5575 5564 0 Nov11? 00:00:04/usr/lib64/heartbeat/ccm
496 5576 5564 0 Nov11? 00:00:07/usr/lib64/heartbeat/cib
Nobody 5577 5564 0 Nov11? 00:00:03/usr/lib64/heartbeat/lrmd-r
Nobody 5578 5564 0 Nov11? 00:00:04/usr/lib64/heartbeat/stonithd
496 5579 5564 0 Nov11? 00:00:02/usr/lib64/heartbeat/attrd
496 5580 5564 0 Nov11? 00:00:03/usr/lib64/heartbeat/crmd
496 8978 5580 0? 00:00:00/usr/lib64/heartbeat/tengine
496 8979 5580 0? 00:00:00/usr/lib64/heartbeat/pengine
Root 5581 5564 0 Nov11? 00:00:03/usr/lib64/heartbeat/mgmtd-v

### The following figure shows the automatically generated cib. xml file, which does not contain specific resource information.
# Cd/var/lib/heartbeat/crm
# Ls-hltr
Total 16 K
-Rw ------- 2 hacluster haclient 484 Nov 11 cib. xml. last
-Rw ------- 2 hacluster haclient 484 Nov 11 cib. xml
-Rw-r -- 2 hacluster haclient 32 Nov 11 16:54 cib. xml. sig. last
-Rw-r -- 2 hacluster haclient 32 Nov 11 16:54 cib. xml. sig

# Ifconfig | grep eth0: 0
# Ssh orasrv2 'ifconfig | grep eth0: 0-A2 '### at this time, the vip is on the second node.
Eth0: 0 Link encap: Ethernet HWaddr 00: 0C: 29: F1: 2E: E4
Inet addr: Bcast: Mask:
Up broadcast running multicast mtu: 1500 Metric: 1

3. Use crm commands to manage Clusters
Crm-related command line tools, usually located at/usr/sbin
All commands can be obtained through <command> -- help

Crm_verify -- check the cluster configuration file
Crm_uuid -- view the node uuid
Crm_standby -- standby attribute of the Operation node to determine whether the resource can run on this node
Crm_resource -- Resource Management Tool
Crm_mon -- cluster Health Status Monitoring
Crm_master -- choose settings for managing Master/Slave resources to improve on a given Node
Crm_failcount -- manages the counters that record the fault count of each resource.
Crm_diff -- identify the changes to the cluster configuration and apply the supplemental program to the configuration file
Crm_attribute -- allows you to query, modify, and delete node attributes and cluster options.
Crmadmin -- Control Cluster Resource Manager
Crm_sh -- tool set in the crm Command Prompt
Cibadmin-provides direct access to cluster configurations

# Crm_verify-x/var/lib/heartbeat/crm/cib. xml ### verify the configuration file
# Crm_uuid ### view node uuid
# Ssh orasrv2 crm_uuid

# Crm_resource -- list ### view resources. Currently, no resources exist.
NO resources configured

# Crm_mon-1 ### cluster status monitoring. The current two nodes are online.
Last updated: Wed Nov 11 17:14:18 2015
Current DC: (6ae0f853-b98c-470b-9ce9-4cd0077179ee)
2 Nodes configured.
0 Resources configured.
Node: (6ae0f853-b98c-470b-9ce9-4cd0077179ee): online
Node: (512505ec-63f0-4a51-be40-58ba0e2f613d): online

Convert the haresources file resource to CIB xml
### Use haresources2cib. py to convert the content of the haresource file to the CIB xml file
#/Usr/lib64/heartbeat/haresources2cib. py
Cib. xml or cib. xml. sig exist in/var/lib/heartbeat/crm/
Please remove them before generating new cib. xml
# Mkdir/var/lib/heartbeat/crm/old
# Mv/var/lib/heartbeat/crm/cib */var/lib/heartbeat/crm/old
#/Usr/lib64/heartbeat/haresources2cib. py
# Ls/var/lib/heartbeat/crm/
Cib. xml old

### Restart 2 nodes
# Service heartbeat restart ### Node 1
# Ssh orasrv2 'service heartbeat restart' ### Node 2

# Crm_resource -- list ### view all resources with a group of resources
Resource Group: group_1
IPaddr_192_168_21_1 (ocf: heartbeat: IPaddr)
Httpd_2 (lsb: httpd)

[Root @ orasrv1 ~] # Crm_resource-Q-r IPaddr_192_168_21_1 ### query a specified resource
Resource Group: group_1
IPaddr_192_168_21_1 (ocf: heartbeat: IPaddr)
Httpd_2 (lsb: httpd)

[Root @ orasrv1 ~] # Crm_resource-QW-r IPaddr_192_168_21_1 ### query the node where the resource is located

# Crmadmin -- version
HA Version 2.1.4, CRM Version 2.0 (CIB feature set 2.0) node: aa909246edb2017137b986c5773344b98c6969999

[Root @ orasrv1 ~] # Crmadmin -- nodes ### query node Member names
Normal node: (6ae0f853-b98c-470b-9ce9-4cd0077179ee)
Normal node: (512505ec-63f0-4a51-be40-58ba0e2f613d)

# Crm_sh
/Usr/sbin/crm_sh: 31: DeprecationWarning: The popen2 module is deprecated. Use the subprocess module.
From popen2 import Popen3
Crm # help
Usage: crm (nodes | config | resources)
Crm # nodes
Crm nodes # help
Usage: nodes (status | list)
Crm nodes # list
<Node id = "6ae0f853-b98c-470b-9ce9-4cd0077179ee" uname = "" type = "normal"/>
<Node id = "512505ec-63f0-4a51-be40-58ba0e2f613d" uname = "" type = "normal"/>

Crm nodes # config -- unable to switch to the config path
Crm nodes # help
Usage: nodes (status | list)
Crm nodes # resources -- cannot switch to the config path
Crm nodes # help
Usage: nodes (status | list)

### Verify the httpd service. As shown in the following query, the current service is located at 2nd points.
# Curl http: //

### For details about more commands, refer:

Iv. Switch Test
[Root @ orasrv1 crm] # crm_standby-v true
[Root @ orasrv1 crm] # curl http: //

### You can also switch nodes by specifying nodes
### If node 2 is the master node, you can run the command on node 1 to switch it to the slave node.
# Crm_standby-v true-U

V. Summary
1. In Versions later than heartbeat v2, resources managed by haresources can be converted to CIB-based management.
2. For CRM (CIB) management, you need to configure ha. cf and add crm respawn.
3. the CRM and haresources methods are not compatible, that is, either of them
4. You can use crm commands to manage cluster configurations, monitoring, and switching.
5. Use the CRM management method or manage it based on the graphical interface.

Hot Standby for Web Services Based on Heartbeat V1

Heartbeat enables high-availability clusters of Web Services

Heartbeat + LVS + Ldirectord high-availability Load Balancing Solution

DRBD + Heartbeat + NFS High Availability Configuration notes

Heartbeat high availability for MySQL using NFS based on CRM

Heartbeat high-availability httpd simple configuration based on Resources

CentOS 6 High Availability service Heartbeat v3 installation and configuration

This article permanently updates the link address:

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: 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.