Crm 管理工具
一,crm有兩種工作方式
1,批處理模式,就是在shell指令行中直接輸入指令
2,互動式模式(crm(live)#)進入到crmsh中互動執行
二,指令詳解
1,一級子指令
[root@node1 corosync]# crm
crm(live)# help
This is crm shell, a Pacemaker command line interface.
Available commands:
cib manage shadow CIBs //cib沙盒
resource resources management //所有的資源都在這個子指令後定義
configure CRM cluster configuration //編輯叢集配置資訊
node nodes management //叢集節點管理子指令
options user preferences //使用者優先級
history CRM cluster history //指令曆史記錄
site Geo-cluster support
ra resource agents information center //資源代理子指令(所有與資源代理相關的程都在此指令之下)
status show cluster status //顯示目前叢集的狀态資訊
help,? show help (help topics for list of topics)//檢視目前區域可能的指令
end,cd,up go back one level //傳回第一級crm(live)
quit,bye,exit exit the program //退出crm(live)互動模式
2,resource資源狀态控制子指令
crm(live)resource# help
vailable commands:
status show status of resources //顯示資源狀态資訊
start start a resource //啟動一個資源
stop stop a resource //停止一個資源
restart restart a resource //重新開機一個資源
promote promote a master-slave resource //提升一個主從資源
demote demote a master-slave resource //降級一個主從資源
manage put a resource into managed mode //将一個資源加入到管理模式下
unmanage put a resource into unmanaged mode //從管理模式下去除一個資源
migrate migrate a resource to another node //将資源遷移到另一個節點上
unmigrate unmigrate a resource to another node
param manage a parameter of a resource //管理資源的參數
secret manage sensitive parameters //管理敏感參數
meta manage a meta attribute //管理源屬性
utilization manage a utilization attribute
failcount manage failcounts //管理失效計數器
cleanup cleanup resource status //清理資源狀态
refresh refresh CIB from the LRM status //從LRM(LRM本地資源管理)更新CIB(叢集資訊庫),在
reprobe probe for resources not started by the CRM //探測在CRM中沒有啟動的資源
trace start RA tracing //啟用資源代理(RA)追蹤
untrace stop RA tracing //禁用資源代理(RA)追蹤
help show help (help topics for list of topics) //顯示幫助
end go back one level //傳回一級(crm(live)#)
quit exit the program //退出互動式程式
3,configure資源定義子指令
crm(live)configure# help
node define a cluster node //定義一個叢集節點
primitive define a resource //定義資源
monitor add monitor operation to a primitive //對一個資源添加監控選項(如逾時時間,啟動失敗後的操作)
group define a group //定義一個組類型(将多個資源整合在一起)
clone define a clone //定義一個克隆類型(可以設定總的克隆數,每一個節點上可以運作幾個克隆)
ms define a master-slave resource //定義一個主從類型(叢集内的節點隻能有一個運作主資源,其它從的做備用)
rsc_template define a resource template //定義一個資源模闆
location a location preference //定義位置限制優先級(預設運作于那一個節點(如果位置限制的值相同,預設傾向性那一個高,就在那一個節點上運作))
colocation colocate resources //排列限制資源(多個資源在一起的可能性)
order order resources //資源的啟動的先後順序
rsc_ticket resources ticket dependency
property set a cluster property //設定叢集屬性
rsc_defaults set resource defaults //設定資源預設屬性(粘性)
fencing_topology node fencing order //隔離節點順序
role define role access rights //定義角色的通路權限
user define user access rights //定義用使用者通路權限
op_defaults set resource operations defaults //設定資源預設選項
schema set or display current CIB RNG schema
show display CIB objects //顯示叢集資訊庫對
edit edit CIB objects //編輯叢集資訊庫對象(vim模式下編輯)
filter filter CIB objects //過濾CIB對象
delete delete CIB objects //删除CIB對象
default-timeouts set timeouts for operations to minimums from the meta-data
rename rename a CIB object //重命名CIB對象
modgroup modify group //改變資源組
refresh refresh from CIB //重新讀取CIB資訊
erase erase the CIB //清除CIB資訊
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狀态管理和編輯
template edit and import a configuration from a template //編輯或導入配置模闆
commit commit the changes to the CIB //将更改後的資訊送出寫入CIB
verify verify the CIB with crm_verify //CIB文法驗證
upgrade upgrade the CIB to version 1.0 //更新CIB到1.0
save save the CIB to a file //将目前CIB導出到一個檔案中(導出的檔案存于切換crm 之前的目錄)
load import the CIB from a file //從檔案内容載入CIB
graph generate a directed graph
xml raw xml
help show help (help topics for list of topics) //顯示幫助資訊
end go back one level //回到第一級(crm(live)#)
quit exit the program //退出crm互動模式
4,node節點管理子指令
crm(live)# node
crm(live)node# help
Node management and status commands.
status show nodes status as XML //以xml格式顯示節點狀态資訊
show show node //指令行格式顯示節點狀态資訊
standby put node into standby //模拟指定節點離線(standby在後面必須的FQDN)
online set node online // 節點重新上線
maintenance put node into maintenance mode //将一個節點狀态改為maintenance
ready put node into ready mode //将一個節點狀态改為ready
fence fence node //隔離節點
clearstate Clear node state //清理節點狀态資訊
delete delete node //删除 一個節點
attribute manage attributes
utilization manage utilization attributes
status-attr manage status attributes
help show help (help topics for list of topics)
end go back one level //回到上一次
quit exit the program //退出
5,ra資源代理子指令
crm(live)# ra
crm(live)ra# help
classes list classes and providers //為資源代理分類
list list RA for a class (and provider)//顯示一個類别中的提供的資源
meta show meta data for a RA //顯示一個資源代理序的可用參數(如meta ocf:heartbeat:IPaddr2)
providers show providers for a RA and a class
help show help (help topics for list of topics)
end go back one level
quit exit the program
三,執行個體
1,系統資源檢視
crm(live)ra# classes //系統所使用的資源代理
lsb
ocf / heartbeat pacemaker
service
stonith
2,預設系統資源清單
crm(live)ra# list ocf //清單預設系統資源
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,檢視外加的系統資源
crm(live)ra# list lsb //清單外加的系統資源
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,檢視系統資源的參數
crm(live)ra# meta ocf:heartbeat:IPaddr //檢視系統資源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 case of node failure,
clone instances need to be re-allocated on surviving nodes.
This would not be possible if there is already an 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".
。。。。。。。。。。。。。。。。。。。省略。。。。。。。。。。。。。。。。。。。。。。。。
Operations' defaults (advisory minimum):
start timeout=240
promote timeout=90
demote timeout=90
notify timeout=90
stop timeout=100
monitor_Slave timeout=20 interval=20
monitor_Master timeout=20 interval=10
配置資源時設定的屬性值不能小于預設值。
5,屬性修改
crm(live)configure# property stonith-enabled=false //禁用stonith-enable
crm(live)configure# property no-quorum-policy=ignore //忽略投票規則
6,定義一資源所使用的指令
/**
* primitive:定義一資源所使用的指令
* webip:為資源起一個名字
* ocf:heartbeat;IPaddr:所使用資源代理的類别,由誰提供的那一個代理程式
* op monitor 對webip做監控
* interval:間隔時間
* timeout:逾時時間
* on-fail:失敗自起
*/
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 //那些在/etc/init.d/*的腳本就是屬于lsb的
params後面的參數,可以通過meta指令來查找,不同的系統資源參數是不一樣的。
7,定義排列限制
* 定義排列限制
* colocation:排列限制指令
* nginx_web : 限制名
* inf:#(可能性,inf表示永久在一起,也可以是數值)
* webip nginx_res:#資源名稱
crm(live)configure# colocation nginx_web inf: nginx_res webip
8,定義資源啟動順序
* 定義資源啟動順序
* order : 順序限制的指令
* nginx_after_ip : 限制ID
* mandatory: #指定級别(此處有三種級别:mandatory:強制, Optional:可選,Serialize:序列化)
* webip nginx_res:#資源名稱,這裡書寫的先後順序相當重要
crm(live)configure# order nginx_after_ip mandatory: webip nginx_res
9,定義節點權重
* 定義節點權重
* location:節點權重指令
* webip_and_webnfs_and_webserver:限制名稱
* webip 500: node1:webip這個資源的node1節點的權重是500
crm(live)configure# location webip_and_webnfs_and_webserver webip 500: node1
10,定義預設資源屬性
* 定義預設資源屬性
* rsc_defaults:預設資源
* 這樣定義代表叢集中每一個資源的預設權重,隻有當資源服務不在目前節點時,權重才會生效,比如,這裡我定義了三個資源webip、webnfs、webserver,對每一個資源的權重為100,那麼加在一起就變成了300,之前己經定義node1的位置限制的值為500,當node1當機後,重新上線,這樣就切換到node1上了。
crm(live)configure# rsc_defaults resource-stickiness=100
11,删除資源或者節點
crm(live)configure# delete nginx_res //删除一個資源,限制,排序,組等
crm(live)node# delete node1 //删除一個節
12,資源其他
crm(live)configure# verify //稽核
crm(live)configure# commit //送出
crm(live)configure# show //顯示
13,節點挂起和線上
crm(live)node# standby node1 //節點挂起
crm(live)node# online node1 //節點上線
13,清除狀态資訊
crm(live)resource# cleanup mysql_drbd //清空狀态資訊
本文轉自 blackstome 51CTO部落格,原文連結:http://blog.51cto.com/137783/1968789,如需轉載請自行聯系原作者