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 -hYou 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 filenameFor example, the following command saves the raw xml from the CIB into a file named testfile.
# pcs cluster cib testfileYou can display the status of the cluster and the cluster resources with the following command.
# pcs statusYou 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 commandsFor example, the following command displays the status of the cluster resources.
# pcs status resourcesThe following command displays the status of the cluster, but not the cluster resources.
# pcs cluster statuspcs 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: Authorizedpcs 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
firewallddaemon, 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 haclusterChanging password for user hacluster. New password: Retype new password: passwd: all authentication tokens updated successfully. - Execute the following commands to start the
pcsdservice and to enablepcsdat system start.#systemctl start pcsd.service#systemctl enable pcsd.service
- Authenticate user
haclusteron the new cluster node.[root@clusternode-01 ~]#pcs cluster auth newnode.example.comUsername: hacluster Password: newnode.example.com: Authorized
- Add the new node to the existing cluster. This command also syncs the cluster configuration file
corosync.confto 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 startStarting 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 nodeIf 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 movepcs 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 disablepcs 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.xmlCopy the saved file to the working file you will be using for the configuration updates.
# cp original.xml updated.xmlUpdate your configuration as needed. The following command creates a resource in the file
updated.xmlbut 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=30sPush 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 filenameWhen 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