summaryrefslogtreecommitdiffstats
path: root/doc/sphinx/Pacemaker_Administration/pcs-crmsh.rst
blob: 3eda60adfa7d3cfa13c4abb3864e3f2e80869b8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
Quick Comparison of pcs and crm shell
-------------------------------------

``pcs`` and ``crm shell`` are two popular higher-level command-line interfaces
to Pacemaker. Each has its own syntax; this chapter gives a quick comparion of
how to accomplish the same tasks using either one. Some examples also show the
equivalent command using low-level Pacmaker command-line tools.

These examples show the simplest syntax; see the respective man pages for all
possible options.

Show Cluster Configuration and Status
#####################################

.. topic:: Show Configuration (Raw XML)

   .. code-block:: none

      crmsh     # crm configure show xml
      pcs       # pcs cluster cib
      pacemaker # cibadmin -Q

.. topic:: Show Configuration (Human-friendly)

   .. code-block:: none

      crmsh # crm configure show
      pcs   # pcs config
    
.. topic:: Show Cluster Status

   .. code-block:: none

      crmsh     # crm status
      pcs       # pcs status
      pacemaker # crm_mon -1

Manage Nodes
############

.. topic:: Put node "pcmk-1" in standby mode

   .. code-block:: none

      crmsh     # crm node standby pcmk-1
      pcs-0.9   # pcs cluster standby pcmk-1
      pcs-0.10  # pcs node standby pcmk-1
      pacemaker # crm_standby -N pcmk-1 -v on

.. topic:: Remove node "pcmk-1" from standby mode

   .. code-block:: none

      crmsh     # crm node online pcmk-1
      pcs-0.9   # pcs cluster unstandby pcmk-1
      pcs-0.10  # pcs node unstandby pcmk-1
      pacemaker # crm_standby -N pcmk-1 -v off

Manage Cluster Properties
#########################

.. topic:: Set the "stonith-enabled" cluster property to "false"

   .. code-block:: none

      crmsh     # crm configure property stonith-enabled=false
      pcs       # pcs property set stonith-enabled=false
      pacemaker # crm_attribute -n stonith-enabled -v false

Show Resource Agent Information
###############################

.. topic:: List Resource Agent (RA) Classes

   .. code-block:: none

      crmsh    # crm ra classes
      pcs      # pcs resource standards
      pacmaker # crm_resource --list-standards

.. topic:: List Available Resource Agents (RAs) by Standard

   .. code-block:: none

      crmsh     # crm ra list ocf
      pcs       # pcs resource agents ocf
      pacemaker # crm_resource --list-agents ocf

.. topic:: List Available Resource Agents (RAs) by OCF Provider

   .. code-block:: none

      crmsh     # crm ra list ocf pacemaker
      pcs       # pcs resource agents ocf:pacemaker
      pacemaker # crm_resource --list-agents ocf:pacemaker

.. topic:: List Available Resource Agent Parameters

   .. code-block:: none

      crmsh     # crm ra info IPaddr2
      pcs       # pcs resource describe IPaddr2
      pacemaker # crm_resource --show-metadata ocf:heartbeat:IPaddr2

You can also use the full ``class:provider:type`` format with crmsh and pcs if
multiple RAs with the same name are available.

.. topic:: Show Available Fence Agent Parameters

   .. code-block:: none

      crmsh # crm ra info stonith:fence_ipmilan
      pcs   # pcs stonith describe fence_ipmilan

Manage Resources
################

.. topic:: Create a Resource

   .. code-block:: none
      crmsh # crm configure primitive ClusterIP IPaddr2 params ip=192.168.122.120 cidr_netmask=24
      pcs   # pcs resource create ClusterIP IPaddr2 ip=192.168.122.120 cidr_netmask=24

Both crmsh and pcs determine the standard and provider (``ocf:heartbeat``) automatically
since ``IPaddr2`` is unique, and automatically create operations (including
monitor) based on the agent's meta-data.

.. topic:: Show Configuration of All Resources

   .. code-block:: none

      crmsh    # crm configure show
      pcs-0.9  # pcs resource show --full
      pcs-0.10 # pcs resource config

.. topic:: Show Configuration of One Resource

   .. code-block:: none

      crmsh    # crm configure show ClusterIP
      pcs-0.9  # pcs resource show ClusterIP
      pcs-0.10 # pcs resource config ClusterIP

.. topic:: Show Configuration of Fencing Resources

   .. code-block:: none

      crmsh    # crm resource status
      pcs-0.9  # pcs stonith show --full
      pcs-0.10 # pcs stonith config

.. topic:: Start a Resource

   .. code-block:: none

      crmsh     # crm resource start ClusterIP
      pcs       # pcs resource enable ClusterIP
      pacemaker # crm_resource -r ClusterIP --set-parameter target-role --meta -v Started

.. topic:: Stop a Resource

   .. code-block:: none

      crmsh     # crm resource stop ClusterIP
      pcs       # pcs resource disable ClusterIP
      pacemaker # crm_resource -r ClusterIP --set-parameter target-role --meta -v Stopped

.. topic:: Remove a Resource

   .. code-block:: none

      crmsh # crm configure delete ClusterIP
      pcs   # pcs resource delete ClusterIP

.. topic:: Modify a Resource's Instance Parameters

   .. code-block:: none

      crmsh     # crm resource param ClusterIP set clusterip_hash=sourceip
      pcs       # pcs resource update ClusterIP clusterip_hash=sourceip
      pacemaker # crm_resource -r ClusterIP --set-parameter clusterip_hash -v sourceip

crmsh also has an `edit` command which edits the simplified CIB syntax
(same commands as the command line) via a configurable text editor.

.. topic:: Modify a Resource's Instance Parameters Interactively

   .. code-block:: none

      crmsh # crm configure edit ClusterIP

Using the interactive shell mode of crmsh, multiple changes can be
edited and verified before committing to the live configuration:

.. topic:: Make Multiple Configuration Changes Interactively

   .. code-block:: none

      crmsh # crm configure
      crmsh # edit
      crmsh # verify
      crmsh # commit

.. topic:: Delete a Resource's Instance Parameters

   .. code-block:: none

      crmsh     # crm resource param ClusterIP delete nic
      pcs       # pcs resource update ClusterIP nic=  
      pacemaker # crm_resource -r ClusterIP --delete-parameter nic

.. topic:: List Current Resource Defaults

   .. code-block:: none

      crmsh     # crm configure show type:rsc_defaults
      pcs       # pcs resource defaults
      pacemaker # cibadmin -Q --scope rsc_defaults

.. topic:: Set Resource Defaults

   .. code-block:: none

      crmsh # crm configure rsc_defaults resource-stickiness=100
      pcs   # pcs resource defaults resource-stickiness=100
    
.. topic:: List Current Operation Defaults

   .. code-block:: none

      crmsh     # crm configure show type:op_defaults
      pcs       # pcs resource op defaults
      pacemaker # cibadmin -Q --scope op_defaults

.. topic:: Set Operation Defaults

   .. code-block:: none

      crmsh # crm configure op_defaults timeout=240s
      pcs   # pcs resource op defaults timeout=240s

.. topic:: Enable Resource Agent Tracing for a Resource

   .. code-block:: none

      crmsh # crm resource trace Website

.. topic:: Clear Fail Counts for a Resource

   .. code-block:: none

      crmsh     # crm resource cleanup Website
      pcs       # pcs resource cleanup Website
      pacemaker # crm_resource --cleanup -r Website

.. topic:: Create a Clone Resource

   .. code-block:: none

      crmsh # crm 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

.. topic:: Create a Promotable Clone Resource

   .. code-block:: none

      crmsh    # crm configure ms WebDataClone WebData \
                 meta master-max=1 master-node-max=1 \
                 clone-max=2 clone-node-max=1 notify=true
      crmsh    # crm configure clone WebDataClone WebData \
                 meta promotable=true \
                 promoted-max=1 promoted-node-max=1 \
                 clone-max=2 clone-node-max=1 notify=true
      pcs-0.9  # pcs resource master WebDataClone WebData \
                 master-max=1 master-node-max=1 \
                 clone-max=2 clone-node-max=1 notify=true
      pcs-0.10 # pcs resource promotable WebData WebDataClone \
                 promoted-max=1 promoted-node-max=1 \
                 clone-max=2 clone-node-max=1 notify=true

crmsh supports both ways ('configure ms' is deprecated) to configure promotable clone since crmsh 4.4.0.
pcs will generate the clone name automatically if it is omitted from the
command line.


Manage Constraints
##################

.. topic:: Create a Colocation Constraint

   .. code-block:: none

      crmsh # crm configure colocation website-with-ip INFINITY: WebSite ClusterIP
      pcs   # pcs constraint colocation add ClusterIP with WebSite INFINITY

.. topic:: Create a Colocation Constraint Based on Role

   .. code-block:: none

      crmsh # crm configure colocation another-ip-with-website inf: AnotherIP WebSite:Master
      pcs   # pcs constraint colocation add Started AnotherIP with Promoted WebSite INFINITY

.. topic:: Create an Ordering Constraint

   .. code-block:: none

      crmsh # crm configure order apache-after-ip mandatory: ClusterIP WebSite
      pcs   # pcs constraint order ClusterIP then WebSite

.. topic:: Create an Ordering Constraint Based on Role

   .. code-block:: none

      crmsh # crm configure order ip-after-website Mandatory: WebSite:Master AnotherIP
      pcs   # pcs constraint order promote WebSite then start AnotherIP

.. topic:: Create a Location Constraint

   .. code-block:: none

      crmsh # crm configure location prefer-pcmk-1 WebSite 50: pcmk-1
      pcs   # pcs constraint location WebSite prefers pcmk-1=50
    
.. topic:: Create a Location Constraint Based on Role

   .. code-block:: none

      crmsh # crm configure location prefer-pcmk-1 WebSite rule role=Master 50: \#uname eq pcmk-1
      pcs   # pcs constraint location WebSite rule role=Promoted 50 \#uname eq pcmk-1

.. topic:: Move a Resource to a Specific Node (by Creating a Location Constraint)

   .. code-block:: none

      crmsh     # crm resource move WebSite pcmk-1
      pcs       # pcs resource move WebSite pcmk-1
      pacemaker # crm_resource -r WebSite --move -N pcmk-1
    
.. topic:: Move a Resource Away from Its Current Node (by Creating a Location Constraint)

   .. code-block:: none

      crmsh     # crm resource ban Website pcmk-2
      pcs       # pcs resource ban Website pcmk-2
      pacemaker # crm_resource -r WebSite --move

.. topic:: Remove any Constraints Created by Moving a Resource

   .. code-block:: none

      crmsh     # crm resource unmove WebSite
      pcs       # pcs resource clear WebSite
      pacemaker # crm_resource -r WebSite --clear

Advanced Configuration
######################

Manipulate Configuration Elements by Type
_________________________________________

.. topic:: List Constraints with IDs

   .. code-block:: none

      pcs   # pcs constraint list --full

.. topic:: Remove Constraint by ID

   .. code-block:: none

      pcs   # pcs constraint remove cli-ban-Website-on-pcmk-1
      crmsh # crm configure remove cli-ban-Website-on-pcmk-1

crmsh's `show` and `edit` commands can be used to manage resources and
constraints by type:

.. topic:: Show Configuration Elements

   .. code-block:: none

      crmsh # crm configure show type:primitive
      crmsh # crm configure edit type:colocation

Batch Changes
_____________

.. topic:: Make Multiple Changes and Apply Together

   .. code-block:: none

      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-0.9  # 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-0.10 # pcs -f drbd_cfg resource promotable WebData WebDataClone \
                 promoted-max=1 promoted-node-max=1 clone-max=2 clone-node-max=1 notify=true
      pcs      # pcs cluster cib-push drbd_cfg

Template Creation
_________________

.. topic:: Create Resource Template Based on Existing Primitives of Same Type

   .. code-block:: none

      crmsh # crm configure assist template ClusterIP AdminIP

Log Analysis
____________

.. topic:: Show Information About Recent Cluster Events

   .. code-block:: none

      crmsh # crm history
      crmsh # peinputs
      crmsh # transition pe-input-10
      crmsh # transition log pe-input-10

Configuration Scripts
_____________________

.. topic:: Script Multiple-step Cluster Configurations

   .. code-block:: none

      crmsh # crm script show apache
      crmsh # crm script run apache \
              id=WebSite \
              install=true \
              virtual-ip:ip=192.168.0.15 \
              database:id=WebData \
              database:install=true