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.
For more information about heartbeat, see:
HeartBeat cluster component Overview
Install and configure heartbeat in Linux
Configure httpd High Availability Service Based on heartbeat in Linux

1. Description of related configuration files
### Node information # more/etc/hosts127.0.0.1 localhost. localdomain localhost # public ip192.168.21.10 orasrv1.xlk.com orasrv11942521.13 orasrv2.xlk.com orasrv2 # private ip192.168.144.128 orasrv1-priv.xlk.com orasrv1-priv192.168.144.129 orasrv2-priv.xlk.com # configuration file information # cat/etc/ha. d/ha. cf ### ha. cf file logfile/var/log/ha-logkeepalive 2 deadtime 15 warntime 30 initdead 60 udpport 694 bcast eth0auto_failback offnode orasrv1.xlk. comnode orasrv2.xlk. comping 192.168.21.254respawn hacluster/usr/lib64/heartbeat/ipfailcrm respawn # This item defines how to enable crm, or pacemaker (after heartbeat V3) # CRM and Resources are not compatible, if ha. cf defines CRM, and the HA service does not read/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 11 md5 74a6a503b5bec9373b22bb630608df41 # more/etc/ha. d/haresources ### resource file orasrv1.xlk.com IPaddr: 192.168.21.1 httpd ### use ha_propagate to synchronize the configuration file. Note, does not contain the haresource file ### scp command method used by ha_propagate based on equivalent ssh, at the same time, use chkconfig to enable heartbeat for self-starting [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 mgmtd port tcp 0 0 0.0.0.0: 5560 0.0.0.0: * LISTEN 4128/mgmtd # ssh orasrv2 'netstat-nltp | grep 5560 'tcp 0 0.0.0.0: 5560 0.0.0.0: * LISTEN 3434/mgmtd ### view heartbeat processes # ps-AHfww | grep heartbeat | grep-v greproot 5564 1 0 Nov11? 00:00:40 heartbeat: master control processnobody 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 192.168.21.254nobody 5571 5564 0 Nov11? 00:00:02 heartbeat: read: ping 192.168.21.254496 5575 5564 0 Nov11? 00:00:04/usr/lib64/heartbeat/ccm496 5576 5564 0 Nov11? 00:00:07/usr/lib64/heartbeat/cibnobody 5577 5564 0 Nov11? 00:00:03/usr/lib64/heartbeat/lrmd-rnobody 5578 5564 0 Nov11? 00:00:04/usr/lib64/heartbeat/stonithd496 5579 5564 0 Nov11? 00:00:02/usr/lib64/heartbeat/attrd496 5580 5564 0 Nov11? 00:00:03/usr/lib64/heartbeat/crmd496 8978 5580 0? 00:00:00/usr/lib64/heartbeat/tengine496 8979 5580 0? 00:00:00/usr/lib64/heartbeat/pengineroot 5581 5564 0 Nov11? 00:00:03/usr/lib64/heartbeat/mgmtd-v ### the automatically generated cib is displayed below. xml file, which does not contain specific resource information # cd/var/lib/heartbeat/crm # ls-hltrtotal 16K-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 address is in the second node eth0: 0 Link encap: Ethernet HWaddr 00: 0C: 29: F1: 2E: E4 inet addr: 192.168.21.1 Bcast: 192.168.21.255 Mask: 255.255.255.0 up broadcast running multicast mtu: 1500 Metric: 1
3. Use crm commands to manage Clusters
Crm-related command line tools. Generally, all commands in/usr/sbin can run through
 


-- Help method to obtain help crm_verify -- check the cluster configuration file crm_uuid -- view the node's uuid crm_standby -- operate on the slave attributes of the node to determine whether the resource can run crm_resource on this node -- resource management tool crm_mon -- cluster health status monitoring crm_master -- choose settings for managing Master/Slave resources, to increase crm_failcount on a given node -- the counter that manages the fault count of each resource. Crm_diff -- identifies changes to the cluster configuration and applies 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 cibadmin at the crm command prompt -- provides direct access to cluster configuration # crm_verify-x/var/lib/heartbeat/crm/cib. xml ### check configuration file # crm_uuid ### view node uuid verification # ssh orasrv2 crm_uuid 6ae0f853-b98c-470b-9ce9-4cd0077179ee # crm_resource -- list ## view resources, currently, NO resources are available for NO resources configured # crm_mon-1 ### cluster status monitoring. Currently, 2 nodes are online ============= Last updated: wed Nov 11 17:14:18 2015 Current DC: Orasrv2.xlk.com (6ae0f853-b98c-470b-9ce9-4cd0077179ee) 2 Nodes configured. 0 Resources configured. ============ Node: orasrv2.xlk.com (6ae0f853-b98c-470b-9ce9-4cd0077179ee): online Node: orasrv1.xlk.com (region ): online haresources file resources are transferred to CIB xml ### use haresources2cib. py converts 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, there is a Group of Resource groups: Group_1 IPaddr_192_168_21_1 (ocf: heartbeat: IPaddr) httpd_2 (lsb: httpd) [root @ orasrv1 ~] # Crm_resource-Q-r records ### query the specified 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 orasrv1.xlk.com # crmadmin -- version HA Version 2.1.4, CRM Version 2.0 (CIB feature set 2.0) node of the Resource: aa909246edb109137b986c5773344b98c6969999 [root @ orasrv1 ~] # Crmadmin -- nodes ### query node Member names normal node: orasrv2.xlk.com (region) normal node: orasrv1.xlk.com (region) # 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 Crm nodes # config -- unable to switch to crm nodes # help Usage: nodes (status | list) crm nodes # resources under the config path -- likewise, crm nodes # help Usage: nodes (status | list) ### verify the httpd service. The following query shows that the current service is deployed on 2nd nodes # curl http: // 192.168.21.1/orasrv1.xlk.com ### more detailed description of the command, please refer to: http://www.novell.com/zh-cn/documentation/sle_ha/book_sleha/data/cha_ha_management.html

Iv. Switch Test
[Root @ orasrv1 crm] # crm_standby-v true [root @ orasrv1 crm] # curl http: // 192.168.21.1/orasrv2.xlk.com ### you can also switch through the specified node ### assume that node 2 is the master node, then you can run the command on node 1 to switch it to the slave # crm_standby-v true-U orasrv2.xlk.com
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.

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.