一.概念
1.crmsh
This project is not part of the GNU Project.
Pacemaker command line interface for management and configuration
crmsh不属于GNU,是管理pacemaker的命令行界面,最新版本v1.2.6 RC 3 2013-8-29日发布
crmsh支持自动补全
2.pcs
PCS - Pacemaker/Corosync configuration system
专用于pacemaker+corosync的设置工具,有CLI和web-based GUI界面
二.命令比较
显示集群设置
crmsh # crm configure show
pcs # pcs cluster cib
显示集群状态
crmsh # crm_mon -
1
pcs # pcs status
挂起节点
crmsh # crm node standby
pcs # pcs cluster standby pcmk-
1
crmsh # crm node online
pcs # pcs cluster unstandby pcmk-
1
设置option
crmsh # crm configure property stonith-enabled=
false
pcs # pcs property
set
stonith-enabled=
false
列出可用资源
crmsh # crm ra classes
pcs # pcs resource standards
crmsh # crm ra list ocf pacemaker
pcs # pcs resource agents ocf:pacemaker
创建资源
crmsh # crm configure primitive ClusterIP ocf:heartbeat:IPaddr2
params ip=
192.168
.
122.120
cidr_netmask=
32
op monitor interval=30s
pcs # pcs resource create ClusterIP IPaddr2 ip=
192.168
.
0.120
cidr_netmask=
32
开启资源
crmsh # crm resource start ClusterIP
pcs # pcs resource start ClusterIP
关闭资源
crmsh # crm resource stop ClusterIP
pcs # pcs resource stop ClusterIP
删除资源
crmsh # crm configure
delete
ClusterIP
pcs #
更新资源
crmsh # crm configure edit ClusterIP
pcs # pcs resource update ClusterIP clusterip_hash=sourceip
显示资源
crmsh #
pcs # pcs resource show WebFS
资源默认属性
crmsh # crm configure rsc_defaults resource-stickiness=
100
pcs # pcs resource rsc defaults resource-stickiness=
100
pcs # pcs resource rsc defaults(列出defaults)
操作的默认属性
crmsh # crm configure op_defaults timeout=240s
pcs # pcs resource op defaults timeout=240s
pcs # pcs resource op defaults
资源间关系
crmsh # crm configure colocation website-
with
-ip INFINITY: WebSite ClusterIP
pcs # pcs constraint colocation add WebSite ClusterIP INFINITY
资源顺序
crmsh # crm configure order apache-after-ip mandatory: ClusterIP WebSite
pcs # pcs constraint order ClusterIP then WebSite
节点粘性
crmsh # crm configure location prefer-pcmk-
1
WebSite
50
: pcmk-
1
pcs # pcs constraint location WebSite prefers pcmk-
1
=
50
移动资源
crmsh # crm resource move WebSite pcmk-
1
pcs # pcs resource move WebSite pcmk-
1
crmsh # crm resource unmove WebSite
pcs # pcs resource unmove WebSite
创建克隆资源
crmsh # configure clone WebIP ClusterIP meta globally-unique=
"true"
clone-max=
"2"
clone-node-max=
"2"
pcs # pcs resource clone ClusterIP globally-unique=
true
clone-max=
2
clone-node-max=
2
创建主从资源
crmsh # crm configure ms WebDataClone WebData
meta master-max=
1
master-node-max=
1
clone-max=
2
clone-node-max=
1
notify=
true
pcs # pcs resource master WebDataClone WebData
master-max=
1
master-node-max=
1
clone-max=
2
clone-node-max=
1
notify=
true
脚本
crmsh # crm
crmsh # cib
new
drbd_cfg
crmsh # configure primitive WebData ocf:linbit:drbd params drbd_resource=wwwdata
op monitor interval=60s
crmsh # configure ms WebDataClone WebData meta master-max=
1
master-node-max=
1
clone-max=
2
clone-node-max=
1
notify=
true
crmsh # cib commit drbd_cfg
crmsh # quit
pcs # pcs cluster cib drbd_cfg
pcs # pcs -f drbd_cfg resource create WebData ocf:linbit:drbd drbd_resource=wwwdata
op monitor interval=60s
pcs # pcs -f drbd_cfg resource master WebDataClone WebData master-max=
1
master-node-max=
1
clone-max=
2
clone-node-max=
1
notify=
true
pcs # pcs cluster push cib drbd_cfg