Chapter 3. The pcs command line interface
pcs command line interface controls and configures cluster services such as
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
3.1. pcs help display
You use the
-h option of
pcs to display the parameters of a
pcs command and a description of those parameters.
The following command displays the parameters of the
pcs resource command. Only a portion of the output is shown.
pcs resource -h
3.2. Viewing the raw cluster configuration
Although you should not edit the cluster configuration file directly, you can view the raw cluster configuration with the
pcs cluster cib command.
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
pcs cluster cib testfile
3.3. Saving a configuration change to a working file
When configuring a cluster, you can save configuration changes to a specified file without affecting the active CIB. This allows you to specify configuration updates without immediately updating the currently running cluster configuration with each individual update.
For information on saving the CIB to a file, see Viewing the raw cluster configuration. Once you have created that file, you can save configuration changes to that file rather than to the active CIB by using the
-f option of the
pcs command. When you have completed the changes and are ready to update the active CIB file, you can push those file updates with the
pcs cluster cib-push command.
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
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.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=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
3.4. Displaying cluster status
There are a variety of commands you can use to display the status of a cluster and its components.
You can display the status of the cluster and the cluster resources with the following command.
You can display the status of a particular cluster component with the commands parameter of the
pcs status command, specifying
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
3.5. Displaying the full cluster configuration
Use the following command to display the full current cluster configuration.
3.6. Modifying the corosync.conf file with the pcs command
You can use the
pcs command to modify the parameters in the
The following command modifies the parameters in the
pcs cluster config update [transport transport options] [compression compression options] [crypto crypto options] [totem totem options] [--corosync_conf path]
The following example command udates the
knet_pmtud_interval transport value and the
join totem values.
pcs cluster config update transport knet_pmtud_interval=35 totem token=10000 join=100
- For information on adding and removing nodes from an existing cluster, see Managing cluster nodes.
- For information on adding and modifying links in an existing cluster, see Adding and modifying links in an existing cluster.
- For information on modifyng quorum options and managing the quorum device settings in a cluster, see Configuring cluster quorum. and Configuring quorum devices.
3.7. Displaying the corosync.conf file with the pcs command
The following command displays the contents of the
corosync.conf cluster configuration file.
pcs cluster corosync
You can print the contents of the
corosync.conf file in a human-readable format with the
pcs cluster config command, as in the following example.
pcs cluster configCluster Name: HACluster Transport: knet Nodes: r8-node-01: Link 0 address: r8-node-01 Link 1 address: 192.168.122.121 nodeid: 1 r8-node-02: Link 0 address: r8-node-02 Link 1 address: 192.168.122.122 nodeid: 2 Links: Link 1: linknumber: 1 ping_interval: 1000 ping_timeout: 2000 pong_count: 5 Compression Options: level: 9 model: zlib threshold: 150 Crypto Options: cipher: aes256 hash: sha256 Totem Options: downcheck: 2000 join: 50 token: 10000 Quorum Device: net Options: sync_timeout: 2000 timeout: 3000 Model Options: algorithm: lms host: r8-node-03 Heuristics: exec_ping: ping -c 1 127.0.0.1
You can run the
pcs cluster config show command with the
--output-format=cmd option to display the
pcs configuration commands that can be used to recreate the existing
corosync.conf file, as in the following example.
pcs cluster config show --output-format=cmdpcs cluster setup HACluster \ r8-node-01 addr=r8-node-01 addr=192.168.122.121 \ r8-node-02 addr=r8-node-02 addr=192.168.122.122 \ transport \ knet \ link \ linknumber=1 \ ping_interval=1000 \ ping_timeout=2000 \ pong_count=5 \ compression \ level=9 \ model=zlib \ threshold=150 \ crypto \ cipher=aes256 \ hash=sha256 \ totem \ downcheck=2000 \ join=50 \ token=10000