Useful Corosync and Pacemaker Commands: Difference between revisions

From Integrics Wiki
Jump to navigation Jump to search
Content deleted Content added
Vlasis (talk | contribs)
Created page with "List of useful commands to for Corosync and Pacemaker clusters. * View the real-time status of nodes and resources: crm_mon * View one-off status of nodes and resources: c..."
 
Clarify that given commands need to be executed in only one cluster node
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
List of useful commands to for Corosync and Pacemaker clusters.
List of useful commands for Corosync and Pacemaker clusters.


* View the real-time status of nodes and resources:
* View the real-time status of nodes and resources:


crm_mon
<pre>crm_mon</pre>


* View one-off status of nodes and resources:
* View one-off status of nodes and resources:


crm status
<pre>crm status</pre>


* View cluster configuration:
* View cluster configuration:


crm configure show
<pre>crm configure show</pre>


* Set a node to standby mode, which can be used to simulate a node becoming unavailable:
* Set a node to standby mode (can also be used to simulate a node becoming unavailable):


crm node standby <node name>
<pre>crm node standby <node name></pre>


* Set a node's status from standby to online:
* Set a node's status from standby to online:


crm node online <node name>
<pre>crm node online <node name></pre>


* Start a resource or a resource group:
* Start a resource or a resource group:


crm resource start <resource name>
<pre>crm resource start <resource name></pre>


* Stop a resource or a resource group:
* Stop a resource or a resource group:


crm resource stop <resource name>
<pre>crm resource stop <resource name></pre>


* Restart a resource or a resource group (if the resource is in a resource group then the whole group will be restarted):
* Edit a resource, which allows you to reconfigure it:


crm configure edit <resource name>
<pre>crm resource restart <resource name></pre>

* Edit a resource, which allows its reconfiguration:

<pre>crm configure edit <resource name></pre>


* Delete a resource (must be stopped before it is deleted):
* Delete a resource (must be stopped before it is deleted):


crm configure delete <resource name>
<pre>crm configure delete <resource name></pre>


* Migrate a resource to another node:
* Migrate the enswitch resource group to another node (avoid migrating specific resources separately, migrate the whole enswitch group instead):


crm resource migrate <resource name> <node name>
<pre>crm resource migrate enswitch <node name></pre>


* Configuring a cluster to not manage a resource:
* Configuring a cluster to not manage a resource:


crm_resource --resource <resource name> --set-parameter is-managed --meta --parameter-value false
<pre>crm_resource --resource <resource name> --set-parameter is-managed --meta --parameter-value false</pre>


* Clear a resource that is stuck in "(unmanaged) FAILED" state, e.g. due to a failed stop action:
* Clear a resource that is stuck in "(unmanaged) FAILED" state, e.g. due to a failed stop action:


crm_resource -P
<pre>crm_resource -P
crm resource cleanup <resource name>
crm resource cleanup <resource name></pre>


* List resource agents by type:
* List resource agents by type:
crm ra list lsb
<pre>crm ra list lsb
crm ra list systemd
crm ra list systemd
crm ra list ocf heartbeat
crm ra list ocf heartbeat
crm ra list ocf pacemaker
crm ra list ocf pacemaker</pre>

* Remove a resource from a group without disturbing the remaining resources:
<pre>crm configure property maintenance-mode=true
crm resource stop <resource> # it won't stop as it's in maintenance-mode
crm configure delete <resource>
crm configure show # verify that all references to <resource> are gone
crm resource reprobe # the cluster double checks the status of declared resources and verifies that everything is in order and <resource> doesn't exist anymore
crm_mon -Arf1 # double check that everything is "started (unmanaged)" and <resource> is gone
crm_simulate -S -L -VVV # optional, to check what would happen when leaving maintenance-mode
crm configure property maintenance-mode=false</pre>

If something goes wrong while in maintenance-mode then

<pre>crm resource cleanup <resource></pre>

might be handy.

* Edit the cluster configuration with the ''cibadmin'' cluster tool:

<pre>cibadmin --query > /tmp/old_cluster_configuration.xml
cp /tmp/old_cluster_configuration.xml /tmp/new_cluster_configuration.xml
# with any editor, e.g vim, apply any needed changes to the cluster configuration
vim /tmp/new_cluster_configuration.xml
cibadmin --replace --xml-file /tmp/new_cluster_configuration.xml</pre>

That sequence of commands needs to be executed in only one cluster node. After that, all the other nodes will receive and apply the updated configuration.

* Set custom values for the ''monitoring interval'' and ''stop timeout'' for a ''systemd'' resource:

In the following example a cluster resource of ''systemd'' type will be created, setting a ''monitoring interval'' of 30 seconds and a ''stop timeout'' of 40 seconds.

<pre>crm configure primitive <resource name> \
systemd:<sytemd name that corresponds to the cluster resource> \
op monitor interval="30s" \
op stop timeout="40s"
</pre>

If the cluster resource already exists, it could be edited to set those custom values, as illustrated in the previous examples.

Latest revision as of 16:19, 4 January 2022

List of useful commands for Corosync and Pacemaker clusters.

  • View the real-time status of nodes and resources:
crm_mon
  • View one-off status of nodes and resources:
crm status
  • View cluster configuration:
crm configure show
  • Set a node to standby mode (can also be used to simulate a node becoming unavailable):
crm node standby <node name>
  • Set a node's status from standby to online:
crm node online <node name>
  • Start a resource or a resource group:
crm resource start <resource name>
  • Stop a resource or a resource group:
crm resource stop <resource name>
  • Restart a resource or a resource group (if the resource is in a resource group then the whole group will be restarted):
crm resource restart <resource name>
  • Edit a resource, which allows its reconfiguration:
crm configure edit <resource name>
  • Delete a resource (must be stopped before it is deleted):
crm configure delete <resource name>
  • Migrate the enswitch resource group to another node (avoid migrating specific resources separately, migrate the whole enswitch group instead):
crm resource migrate enswitch <node name>
  • Configuring a cluster to not manage a resource:
crm_resource --resource <resource name> --set-parameter is-managed --meta --parameter-value false
  • Clear a resource that is stuck in "(unmanaged) FAILED" state, e.g. due to a failed stop action:
crm_resource -P
crm resource cleanup <resource name>
  • List resource agents by type:
crm ra list lsb
crm ra list systemd
crm ra list ocf heartbeat
crm ra list ocf pacemaker
  • Remove a resource from a group without disturbing the remaining resources:
crm configure property maintenance-mode=true
crm resource stop <resource> # it won't stop as it's in maintenance-mode
crm configure delete <resource>
crm configure show # verify that all references to <resource> are gone
crm resource reprobe # the cluster double checks the status of declared resources and verifies that everything is in order and <resource> doesn't exist anymore
crm_mon -Arf1 # double check that everything is "started (unmanaged)" and <resource> is gone
crm_simulate -S -L -VVV # optional, to check what would happen when leaving maintenance-mode
crm configure property maintenance-mode=false

If something goes wrong while in maintenance-mode then

crm resource cleanup <resource>

might be handy.

  • Edit the cluster configuration with the cibadmin cluster tool:
cibadmin --query > /tmp/old_cluster_configuration.xml
cp /tmp/old_cluster_configuration.xml /tmp/new_cluster_configuration.xml
# with any editor, e.g vim, apply any needed changes to the cluster configuration
vim /tmp/new_cluster_configuration.xml
cibadmin --replace --xml-file /tmp/new_cluster_configuration.xml

That sequence of commands needs to be executed in only one cluster node. After that, all the other nodes will receive and apply the updated configuration.

  • Set custom values for the monitoring interval and stop timeout for a systemd resource:

In the following example a cluster resource of systemd type will be created, setting a monitoring interval of 30 seconds and a stop timeout of 40 seconds.

crm configure primitive <resource name> \
  systemd:<sytemd name that corresponds to the cluster resource> \
  op monitor interval="30s" \
  op stop timeout="40s"

If the cluster resource already exists, it could be edited to set those custom values, as illustrated in the previous examples.