Corosync+pacemaker's Crmsh CRM example

Source: Internet
Author: User
Tags sub command time interval

Corosync and pacemaker implementation of the high availability of the difficulties in the CRM command, subcommand, more parameters, and so on, the following some common examples.
One, CRM has two kinds of working methods

1, batch mode, which is to enter commands directly on the shell command line
2, interactive mode (CRM (live) #) enters into Crmsh for interactive execution

Second, the order detailed

1, First ORDER subcommand

The code is as follows Copy Code
[Root@node1 corosync]# CRM


CRM (live) # Help


This is the CRM shell, a Pacemaker command line interface.


Available commands:


CIB manage Shadow CIBs//CIB sand Box


Resource resource management//All resources are defined after this sub command


Configure CRM cluster configuration//Edit cluster configuration information


Node nodes management//cluster Nodes admin subcommand


Options user Preferences//Priority


History CRM Cluster history//Command history


Site Geo-cluster Support


RA Resource Agents Information Center/resource Agent subcommand (all processes associated with the resource agent are under this command)


Status Show cluster status//display current cluster state information


Help, huh? Show Help (Help topics for List of topics)//view possible commands for the current zone


End,cd,up go back one level//return to First Class CRM (live)


Quit,bye,exit exit the program//Exit CRM (live) Interactive mode


2,resource Resource State CONTROL subcommand

The code is as follows Copy Code
CRM (live) resource# help


vailable commands:


Status Show status in Resources//display resource status information


Start start a resource/a resource


Stop stop a resource/a resource


Restart restart a resource/reboot a resource


promote promote a master-slave resource//promotion of a master-slave resource


Demote demote a Master-slave resource//demote a master-slave resource


Manage put a resource into managed mode//Add a resource to admin mode


Unmanage put a resource into unmanaged mode/remove a resource from admin mode


Migrate migrate a resource to another node//migrate resources to another node


Unmigrate Unmigrate A resource to another node


Param manage a parameter of a resource//management resource parameters


Secret Manage sensitive parameters//management of sensitive parameters


Meta manage a meta attribute//Manage Source Properties


Utilization Manage a Utilization attribute


Failcount Manage failcounts//Management failure counters


Cleanup Cleanup Resource status//cleanup resource status


Refresh Refresh CIB from the LRM status//Update CIB (cluster information Base) from LRM (LRM Local resource management), in


Reprobe probe for resource not started by the CRM//probing resources that are not started in CRM


Trace start RA tracing//Enable Resource Agent (RA) tracking


Untrace Stop RA Tracing//Disable resource Agent (RA) tracking


Help topics for List of topics//Display assistance


End went back one level//Return (CRM (live) #)


Quit exit the program//Exit Interactive


3,configure Resource Definition Child command

The code is as follows Copy Code
CRM (live) configure# help


Available commands:


Node define a cluster node//define a cluster nodes


Primitive define a resource//define Resources


Monitor add monitor operation to a primitive//Add monitoring options to a resource (such as timeout, operation after startup failure)


Group define a groups//define a set type (combine multiple resources)


Clone define a clones//defines a clone type (you can set the total number of clones, and several clones can be run on each node)


Ms Define a Master-slave resource//define a master-slave type (nodes within a cluster can only have one running master resource, others from the standby)


Rsc_template Define a resource template//define a resource template


Location a location preference//defines the position constraint precedence (the default is run on that node (if the value of the position constraint is the same, the default bias is high, run on that node))


colocation colocate Resources//Routing constraints (possibility of multiple resources together)


Order of resources//resource start sequence


Rsc_ticket Resources Ticket Dependency


Property set a cluster//set cluster properties


Rsc_defaults Set resource defaults//Set resource default properties (sticky)


Fencing_topology node Fencing order//Isolation nodes sequence


Role define roles access rights//define the access rights of the persona


User define user access rights//define access rights with users


Op_defaults Set Resource Operations defaults//Set resource default options


Schema set or display current CIB RNG schema


Show display CIB objects//display cluster information base on


Edit edit CIB objects//Edit the Cluster info object (VIM mode edit)


Filter filter CIB objects//Filter CIB objects


Delete Delete CIB objects//Delete CIB object


Default-timeouts set timeouts for operations to minimums from the Meta-data


Rename Rename a CIB object//Rename CIB objects


Modgroup Modify Group//Change resource groups


Refresh Refresh from CIB//re-read CIB information


Erase erase the CIB/clear CIB information


Ptest Show cluster actions if changes were committed


Rsctest test resources as currently configured


CIB CIB Shadow Management


Cibstatus CIB status Management and editing//CIB state management and editing


Template Edit and import a configuration from a template//edit or import configuration template


Commit the changes to the CIB//submit the changed information to the write CIB


Verify verify the CIB with crm_verify//CIB syntax validation


Upgrade Upgrade the CIB to version 1.0//upgrade CIB to 1.0


Save Save the CIB to a file//export the current CIB to a document (a directory where the exported file exists before switching CRM)


Load Import the CIB from a file//load from the contents of the CIB


Graph generate a directed graph


XML RAW XML


Help topics for List of topics//Display assistance information


End goes back one level//return to first tier (CRM (live) #)


Quit exit the program//exit CRM Interactive mode


4,node Node Admin subcommand

The code is as follows Copy Code
CRM (live) # node


CRM (live) node# help


Node Management and Status commands.


Available commands:


Status Show nodes status as XML//Display node state information in XML format


Show shows node//command line format displays nodes state information


Standby put node into standby//simulate the specified node offline (standby must be followed by the FQDN)


Online set node online//node back online


Maintenance put node into maintenance Mode///Change one node state to maintenance


Ready put node into ready mode///Change one node state to ready


Fence Fence node//Isolation Nodes


Clearstate Clear Node state//Cleanup nodes status information


Delete Delete node//delete one of the nodes


Attribute Manage attributes


Utilization Manage Utilization attributes


Status-attr Manage Status Attributes


Help topics for List of topics


End goes back one level//return to last time


Quit exit the program//exit


5,ra Resource Agent Child command

The code is as follows Copy Code
CRM (live) # RA


CRM (live) ra# help


Available commands:


Classes list classes and providers//resource agent classification


The list list RA for a class (and provider)//shows the resources provided in a category


Meta show meta-data for a RA//display available parameters for a resource agent order (such as Meta OCF:HEARTBEAT:IPADDR2)


Providers show providers for a RA and a class


Help topics for List of topics


End down one level


Quit exit the program


Third, the example
1, System resources view

The code is as follows Copy Code
Resource agents used by the CRM (live) ra# classes//System
Lsb
Ocf/heartbeat Pacemaker
Service
Stonith

2, the default system resource list

The code is as follows Copy Code
CRM (Live) ra# list OCF//list default system resources


Ctdb Clustermon Delay Dummy filesystem healthcpu


IPAddr IPaddr2 ipsrcaddr healthcpu healthsmart HealthSmart


LVM MailTo Route Sendarp Squid


Stateful sysinfo systemhealth Virtualdomain Xinetd


Apache CONNTRACKD controld DB2 DHCPD


Ethmonitor exportfs Iscsilogicalunit MySQL named


Nfsnotify nfsserver pgsql Ping Pingd


Postfix remote RSYNCD symlink Tomcat


3, view the additional system resources

The code is as follows Copy Code
CRM (Live) ra# list LSB//list Plus system resources


NetworkManager abrt-ccpp abrt-oops ABRTD acpid


ATD AUDITD AutoFS blk-availability Certmonger


Corosync corosync-notifyd cpuspeed Crond Cups


DNSMASQ firstboot Haldaemon Halt hsqldb


Ip6tables iptables irqbalance jexec kdump


Killall Lvm2-lvmetad lvm2-monitor mdmonitor Messagebus


MYSQLD netconsole Netfs Network NFS


Nfslock nginx NMB ntpd ntpdate


ODDJOBD OpenFire Pacemaker PHP-FPM Portreserve


Postfix psacct quota_nld Rdisc Redis


Restorecond rngd rpcbind RPCGSSD RPCIDMAPD


RPCSVCGSSD Rsyslog Sandbox SASLAUTHD single


SLAPD SMARTD SMB snmpd SNMPTRAPD


Spice-vdagentd sshd SSSD Sysstat udev-post


VSFTPD Wdaemon winbind wpa_supplicant ypbind


4, view the parameters of system resources

The code is as follows Copy Code
CRM (Live) ra# meta ocf:heartbeat:IPaddr//view parameters for system resource IPAddr


Manages virtual IPv4 and IPV6 addresses (Linux specific version) (OCF:HEARTBEAT:IPADDR)





This linux-specific resource manages IP alias IP addresses.


It can add an IP alias, or remove one.


In addition, it can implement Cluster Alias IP functionality


If invoked as a clone resource.





If used as a clone, you should explicitly set Clone-node-max >= 2,


and/or Clone-max < number of nodes. In the case of node failure,


Clone instances need to is re-allocated on surviving nodes.


This would isn't to possible if there is already a instance on those nodes,


and Clone-node-max=1 (which is the default).





Parameters (*: Required, []: Default):





Ip* (String): IPv4 or IPV6 address


The IPv4 (dotted quad notation) or IPV6 address (colon hexadecimal notation)


Example IPv4 "192.168.1.1".


Example IPv6 "2001:db8:dc28:0:0:fc57:d4c8:1fff".


。。。。。。。。。。。。。。。。。。。 Omitted........................


5, Property modification

The code is as follows Copy Code
CRM (Live) configure# property Stonith-enabled=false//Disabled stonith-enable

CRM (Live) configure# property No-quorum-policy=ignore//Ignore voting rules

6, define the command used by a resource

The code is as follows Copy Code
/**
* Primitive: Defines the command used for a resource
* Webip: A name for the resource
* OCF:HEARTBEAT;IPADDR: The type of resource agent used, by whom the agent provided
* OP Monitor to monitor Webip
* Interval: Time interval
* Timeout: Timeout time
* On-fail: Failed from the beginning
*/
CRM (Live) configure# primitive Webip ocf:heartbeat:IPaddr params ip=192.168.10.130 op monitor interval=30s timeout=20s On-fail=restart

CRM (Live) configure# primitive nginx_res Lsb:nginx//The scripts in/etc/init.d/* are the LSB
The parameters behind the params can be found by using meta commands, and different system resource parameters are not the same.

7, defining an arrangement constraint

The code is as follows Copy Code
/**
* Define an arrangement constraint
* colocation: Arranging constraint commands
* Nginx_web: Constraint name
* inf:# (possibility, INF means permanent together, can also be numeric)
* Webip Nginx_res: #资源名称
*/
CRM (Live) configure# colocation nginx_web inf:nginx_res Webip

8, define resource start order

The code is as follows Copy Code
/**
* Define resource start order
* Order: Commands for sequential constraints
* NGINX_AFTER_IP: Constraint ID
* Mandatory: #指定级别 (There are three levels: mandatory: Mandatory, Optional: Optional, Serialize: Serialization)
* Webip nginx_res: #资源名称, the sequence of writing here is very important
*/
CRM (Live) configure# order nginx_after_ip Mandatory:webip Nginx_res

9, define node weights

The code is as follows Copy Code
/**
* Define node weights
* Location: Node weight command
* Webip_and_webnfs_and_webserver: Constraint name
* Webip 500:node1:webip The weight of the Node1 node of this resource is 500
*/
CRM (Live) configure# location Webip_and_webnfs_and_webserver Webip 500:node1

10, define default resource properties

The code is as follows Copy Code
/**
* Define default resource properties
* Rsc_defaults: Default Resource
* This defines the default weights that represent each resource in the cluster. Only when the resource service is not in the current node will the weights take effect, for example, I have defined three resources Webip, Webnfs, webserver, the weight of each resource is 100, then add together will become 300, Previously defined node1 of the value of the position constraint is 500, when Node1 down, back online, so switch to Node1 on.
*/
CRM (Live) configure# rsc_defaults resource-stickiness=100

11, delete the resource or node

The code is as follows Copy Code
CRM (live) configure# Delete nginx_res//delete a resource, constraint, sort, group, etc
CRM (live) node# Delete node1//delete a section

12, other resources

The code is as follows Copy Code
CRM (Live) configure# Verify//Audit
CRM (Live) configure# commit/Submit
CRM (Live) configure# Show//display

13, node hangs and online

  code is as follows copy code
crm (live) node # Standby node1  //node hang  
CRM (live) node# online node1   //node online  

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.