Examples Using PCS Command on Linux- Part 1

Examples Using pcs cluster Command

In this article, we will see that the pcs command line interface controls.

Pacemaker

Pacemaker is an Open Source, High Availability resource manager suitable for both small and large clusters. It is responsible for a deployed software indirectly perhaps even whole systems or their interconnections. It uses messaging and membership capabilities provided by  Corosync to keep the resource available on any of the cluster nodes.

Pacemaker’s key features include:

  • Detection and recovery of node and application-level failures.
  • Supports practically any redundancy configuration.
  • Supports both quorate and resource-driven clusters.
  • Configurable strategies for dealing with quorum loss (when multiple nodes fail).
  • Supports application startup/shutdown ordering, regardless node(s) the applications are on.
  • Supports applications that must/must-not run on the same node.
  • Supports applications which need to be active on multiple nodes.
  • Supports applications with multiple modes (eg. master/slave).
  • Provably correct response to any failure or cluster state. The cluster’s response to any stimuli can be tested offline before the condition exists.
  • Automatically replicated configuration that can be updated from any node.

Corosync

In previous red-hat cluster release, “cman” was responsible for cluster interconnect, fencing, Quorum, messaging and membership capabilities. But In RHEL7, With default options, pacemaker clusters using corosync. Corosync is an open-source cluster engine which communicates with multiple cluster nodes and updates the cluster information database (cib.xml) frequently.

Note: The configuration files for the Red-Hat High Availability add-on are corosync.conf and cib.xml. Do not edit these files directly; use the pcs or pcsd interface instead.

To perform basic cluster administration with Pacemaker, including creating the cluster, managing the cluster components, and displaying cluster status. you can use the “pcs cluster” command;

1) How Authenticating the Cluster Nodes.

The following command authenticates pcs to the pcs daemon on the nodes in the cluster.

#pcs cluster auth [node] […] [-u username] [-p password]

#pcs cluster auth node1.server node2.server -u hacluster -p passwd
node2.server: Authorized
node1.server: Authorized
#

The above command authenticates user hacluster on node1.server for both of the nodes in the cluster that consist of node1.server and node2.server.

Note: Authorization tokens are stored in the file ~ /.pcs/tokens (or /var/lib/pcsd/tokens).

2) How to configuring the Cluster Nodes.

To configures the cluster configuration file and syncs the configuration to the specified nodes the following command is used;

#pcs cluster setup –name cluster_name node1 [node2] […]

#pcs cluster setup --name Mysql_cluster node1.server  node2.server

When we create a cluster with the “pcs cluster setup” command the timeout values for the cluster are set to default values. If your system requires different timeout values, the following options are used.

 

# pcs cluster setup --name Mysql_cluster node1.server  node2.server --token 10000 --join 100

The above following command creates the cluster Mysql_cluster and sets the token timeout value to 10000 milliseconds (10 seconds) and the join timeout value to 100 milliseconds.

3) How to start and stop the Cluster Nodes.

The following command starts cluster services on the specified node or nodes.

#pcs cluster start [–all] [node] […]

The following command starts cluster services on all nodes, when we specify the ‘–all’ option;

#pcs cluster start --all
node1.server: Starting Cluster...
node2.server: Starting Cluster...
#

Similarly below command for stops cluster services on all nodes.

#pcs cluster stop --all
node1.server: Stopping Cluster (pacemaker)...
node2.server: Stopping Cluster (pacemaker)...
node1.server: Stopping Cluster (corosync)...
node2.server: Stopping Cluster (corosync)...
#

By Default, If you do not specify any nodes, cluster services are started on the local node only.

#pcs cluster start
Starting Cluster...
#

To stop the cluster services you can use kill command with the following command, which performs a kill – 9 command.

#pcs cluster kill

4) How to Enabling and Disabling Cluster Services.

To configure the cluster services to run on startup on the specified node or nodes, the following command is used;

#pcs cluster enable --all
node1.server: Cluster Enabled
node2.server: Cluster Enabled
#

The above command enables the cluster services (to run on startup) on all nodes. If you want to enable the service on specific node you can use below following command;

#pcs cluster enable node1.server

Similarly, To configure the cluster services not to run on startup on the specified node or nodes, the following command is used;

#pcs cluster disable --all
node1.server: Cluster Disabled
node2.server: Cluster Disabled
#

5) How to removing the cluster nodes.

To Remove the cluster nodes the following command will shuts down the specified node and removes it from the cluster configuration file, corosync.conf, on all of the other nodes in the cluster.

# pcs status
Cluster name: Mysql_cluster
Stack: corosync
Current DC: node1.server (version 1.1.15-11.el7-e174ec8) - partition with quorum
Last updated: Wed Apr  5 05:19:11 2017          Last change: Wed Apr  5 05:18:49 2017 by hacluster via crmd on node1.server

2 nodes and 1 resource configured
Online: [ node1.server node2.server ]
Full list of resources:

 VirtIP (ocf::heartbeat:IPaddr2):       Started node1.server

Daemon Status:
  corosync: active/disabled
  pacemaker: active/disabled
  pcsd: active/enabled
#pcs cluster node remove node2.server
node2.server: Stopping Cluster (pacemaker)...
node2.server: Successfully destroyed cluster
node1.server: Corosync updated
# pcs status
Cluster name: Mysql_cluster
Stack: corosync
Current DC: node1.server (version 1.1.15-11.el7-e174ec8) - partition with quorum
Last updated: Wed Apr  5 05:13:42 2017          Last change: Wed Apr  5 05:11:38 2017 by root via crm_node on node1.server
1 node and 1 resource configured
Online: [ node1.server ]
Full list of resources:

 VirtIP (ocf::heartbeat:IPaddr2):       Started node1.server

Daemon Status:
  corosync: active/disabled
  pacemaker: active/disabled
  pcsd: active/enabled
#

6) How to add node on existing cluster.

Using following command to add the new node to the existing cluster.

# pcs cluster  node add node2.server
Disabling SBD service...
node2.server: sbd disabled
node1.server: Corosync updated
Setting up corosync...
node2.server: Succeeded
Synchronizing pcsd certificates on nodes node2.server...
node2.server: Success

Restarting pcsd on the nodes in order to reload the certificates...
node2.server: Success
# pcs cluster  start node2.server
# pcs status
Cluster name: Mysql_cluster
Stack: corosync
Current DC: node1.server (version 1.1.15-11.el7-e174ec8) - partition with quorum
Last updated: Wed Apr  5 05:19:11 2017          Last change: Wed Apr  5 05:18:49 2017 by hacluster via crmd on node1.server

2 nodes and 1 resource configured

Online: [ node1.server node2.server ]

Full list of resources:

 VirtIP (ocf::heartbeat:IPaddr2):       Started node1.server

Daemon Status:
  corosync: active/disabled
  pacemaker: active/disabled
  pcsd: active/enabled

6) How to do specified node into standby mode.

This can be used when updating a resource’s packages, the following command is used.

#pcs status
Cluster name: Mysql_cluster
Stack: corosync
Current DC: node1.server (version 1.1.15-11.el7-e174ec8) - partition with quorum
Last updated: Wed Apr  5 04:50:05 2017          Last change: Wed Apr  5 04:49:35 2017 by root via crm_resource on node1.server
2 nodes and 1 resource configured
Online: [ node1.server node2.server ]
Full list of resources:

 VirtIP (ocf::heartbeat:IPaddr2):       Started node1.server
Daemon Status:
  corosync: active/disabled
  pacemaker: active/disabled
  pcsd: active/enabled
#pcs cluster standby node1.server
#pcs status
Cluster name: Mysql_cluster
Stack: corosync
Current DC: node1.server (version 1.1.15-11.el7-e174ec8) - partition with quorum
Last updated: Wed Apr  5 04:51:03 2017          Last change: Wed Apr  5 04:50:48 2017 by root via crm_attribute on node1-server
2 nodes and 1 resource configured
Node node1.server: standby
Online: [ node2.server ]
Full list of resources:

 VirtIP (ocf::heartbeat:IPaddr2):       Started node2.server

Daemon Status:
  corosync: active/disabled
  pacemaker: active/disabled
  pcsd: active/enabled
#

Note: Any resources currently active on the node will be moved to another node. If you specify the –all option(i.e  pcs cluster standby –all) this command puts all nodes into standby mode.

Similarly, to specified node into unstandby mode, the following command is used;

# pcs cluster unstandby node1.server
# pcs status
Cluster name: Mysql_cluster
Stack: corosync
Current DC: node1.server (version 1.1.15-11.el7-e174ec8) - partition with quorum
Last updated: Wed Apr  5 05:10:00 2017          Last change: Wed Apr  5 05:09:59 2017 by root via crm_attribute on node1.server
2 nodes and 1 resource configured
Online: [ node1.server node2.server ]
Full list of resources:

 VirtIP (ocf::heartbeat:IPaddr2):       Started node1.server
Daemon Status:
  corosync: active/disabled
  pacemaker: active/disabled
  pcsd: active/enabled
#

7) How to remove all cluster configuration files.

To permanent(or remove) destroy a cluster, first we have to stop all cluster services and then remove all cluster configuration files, use  following command.

# pcs cluster stop --all
node2.server: Stopping Cluster (pacemaker)...
node1.server: Stopping Cluster (pacemaker)...
node1.server: Stopping Cluster (corosync)...
node2.server: Stopping Cluster (corosync)...
# pcs cluster destroy --all
node1.server: Stopping Cluster (pacemaker)...
node2.server: Stopping Cluster (pacemaker)...
node2.server: Successfully destroyed cluster
node1.server: Successfully destroyed cluster
#

Read Also:

Examples Using PCS Command on Linux- Part 2

Allow Local User to Gives Read/Write Access to the Cluster Configuration.

Hope this post will help Linux/Unix beginners. Please share you feedback and Comments. Stay tune for more updates with ittroubleshooter.in …!!!

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz