11 pcs commands you should know
11 pcs commands you should know
The pcs
command line interface controls and configures cluster services such as corosync
, pacemaker
,booth
, and sbd
by providing an easier interface to their configuration files.
Note that you should not edit the cib.xml
configuration file directly. In most cases, Pacemaker will reject a directly modified cib.xml
file.
1. PCS Help
The following command displays the parameters of the pcs resource
command.
# pcs resource -h
You can save the raw cluster configuration to a specified file with the pcs cluster cib filename
command. If you have previously configured a cluster and there is already an active CIB, you use the following command to save the raw xml file.
pcs cluster cib filename
For example, the following command saves the raw xml from the CIB into a file named testfile
.
# pcs cluster cib testfile
You can display the status of the cluster and the cluster resources with the following command.
# pcs status
You can display the status of a particular cluster component with the commands parameter of the pcs status
command, specifying resources
, cluster
, nodes
, or pcsd
.
pcs status commands
For example, the following command displays the status of the cluster resources.
# pcs status resources
The following command displays the status of the cluster, but not the cluster resources.
# pcs cluster status
pcs cluster auth [node] [...] [-u username] [-p password]
root@z1 ~]# pcs cluster auth z1.example.com z2.example.com
Username: hacluster
Password:
z1.example.com: Authorized
z2.example.com: Authorized
pcs cluster start [--all] [node] [...]
pcs cluster start --all
pcs cluster start
, the --all
option stops cluster services on all nodes and if you do not specify any nodes, cluster services are stopped on the local node only.pcs cluster stop [--all] [node] [...]
kill -9
command.pcs cluster kill
- Install the cluster packages.
[root@newnode ~]#
yum install -y pcs fence-agents-all
- If you are running the
firewalld
daemon, execute the following commands to enable the ports that are required by the Red Hat High Availability Add-On.#
firewall-cmd --permanent --add-service=high-availability
#firewall-cmd --add-service=high-availability
- Set a password for the user ID
hacluster
. It is recommended that you use the same password for each node in the cluster.[root@newnode ~]#
passwd hacluster
Changing password for user hacluster. New password: Retype new password: passwd: all authentication tokens updated successfully. - Execute the following commands to start the
pcsd
service and to enablepcsd
at system start.#
systemctl start pcsd.service
#systemctl enable pcsd.service
- Authenticate user
hacluster
on the new cluster node.[root@clusternode-01 ~]#
pcs cluster auth newnode.example.com
Username: hacluster Password: newnode.example.com: Authorized
- Add the new node to the existing cluster. This command also syncs the cluster configuration file
corosync.conf
to all nodes in the cluster, including the new node you are adding.[root@clusternode-01 ~]#
pcs cluster node add newnode.example.com
- Start and enable cluster services on the new node.
[root@newnode ~]#
pcs cluster start
Starting Cluster... [root@newnode ~]#pcs cluster enable
corosync.conf
, on all of the other nodes in the cluster.pcs cluster node remove node
--all
, this command puts all nodes into standby mode.pcs cluster standby node | --all
--all
, this command removes all nodes from standby mode.pcs cluster unstandby node | --all
pcs cluster standby node
If you need to move an individual resource off the node on which
it is currently running without stopping that resource, you can
use the pcs resource move
pcs resource move
command, this adds a constraint to the resource to prevent it from running on the node on which it is currently running. When you are ready to move the resource back, you can execute the pcs resource clear
or the pcs constraint delete
command to remove the constraint. pcs resource disable
pcs resource unmanage
command.maintenance-mode
cluster property.Procedure
The following is the recommended procedure for pushing changes to the CIB file. This procedure creates a copy of the original saved CIB file and makes changes to that copy. When pushing those changes to the active CIB, this procedure specifies the diff-against
option of the pcs cluster cib-push
command so that only the changes between the original file and the updated file are pushed to the CIB. This allows users to make changes in parallel that do not overwrite each other, and it reduces the load on Pacemaker which does not need to parse the entire configuration file.
Save the active CIB to a file. This example saves the CIB to a file named
original.xml
.# pcs cluster cib original.xml
Copy the saved file to the working file you will be using for the configuration updates.
# cp original.xml updated.xml
Update your configuration as needed. The following command creates a resource in the file
updated.xml
but does not add that resource to the currently running cluster configuration.# pcs -f updated.xml resource create VirtualIP ocf:heartbeat:IPaddr2 ip=192.168.0.120 op monitor interval=30s
Push the updated file to the active CIB, specifying that you are pushing only the changes you have made to the original file.
# pcs cluster cib-push updated.xml diff-against=original.xml
Alternately, you can push the entire current content of a CIB file with the following command.
pcs cluster cib-push filename
When pushing the entire CIB file, Pacemaker checks the version and does not allow you to push a CIB file which is older than the one already in a cluster. If you need to update the entire CIB file with a version that is older than the one currently in the cluster, you can use the --config
option of the pcs cluster cib-push
command.
pcs cluster cib-push --config filename
No comments