Software >> OS >> Unix >> Linux >> RHEL >> HA >> pcs >> What is PCS and how to use pcs command to manage RHEL high availability cluster system


pcs = Pacemaker/Corosync Configuration System

 

## To show overall status

pcs status

(sample output)
Cluster name: mycluster
Stack: corosync
Current DC: rhel7n1.example.com (version 1.1.23-1.el7_9.1-9acf116022) - partition with quorum
Last updated: Sat Oct 23 16:30:44 2021
Last change: Sat Oct 23 15:10:48 2021 by root via cibadmin on rhel7n2.example.com

2 nodes configured
3 resource instances configured

Online: [ rhel7n1.example.com rhel7n2.example.com ]

Full list of resources:

 Resource Group: apache
     httpd_fs   (ocf::heartbeat:Filesystem):    Started rhel7n1.example.com
     httpd_vip  (ocf::heartbeat:IPaddr2):       Started rhel7n1.example.com
     httpd_svc  (ocf::heartbeat:apache):        Started rhel7n1.example.com

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


## To setup up a cluster
## --start will also start on all the nodes

pcs cluster setup --start --name mycluster rhel7n1.example.com rhel7n2.example.com


## To allow the cluster to start on all nodes when the nodes are booted

pcs cluster enable --all


## To show pacemaker properties

pcs property show

(sample output)
Cluster Properties:
 cluster-infrastructure: corosync
 cluster-name: mycluster
 dc-version: 1.1.23-1.el7_9.1-9acf116022
 have-watchdog: false
 stonith-enabled: false


## To show all pacemaker properties

pcs property show --all

(sample output)
Cluster Properties:
 batch-limit: 0
 cluster-delay: 60s
 cluster-infrastructure: corosync
 cluster-ipc-limit: 500
 cluster-name: mycluster
...
 startup-fencing: true
 stonith-action: reboot
 stonith-enabled: false
...
symmetric-cluster: true

## To set a particular property and show that property e.g. stonith-enabled

pcs property set stonith-enabled=false

pcs property show stonith-enabled

(sample output)
Cluster Properties:
 stonith-enabled: false


## To list all available resource types

pcs resource list

(sample output)
lsb:netconsole - Initializes network console logging
lsb:network - Bring up/down networking
lsb:rhnsd - Starts the Spacewalk Daemon
ocf:heartbeat:aliyun-vpc-move-ip - Move IP within a VPC of the Aliyun ECS
ocf:heartbeat:apache - Manages an Apache Web server instance
ocf:heartbeat:aws-vpc-move-ip - Move IP within a VPC of the AWS EC2
ocf:heartbeat:aws-vpc-route53 - Update Route53 VPC record for AWS EC2
ocf:heartbeat:awseip - Amazon AWS Elastic IP Address Resource Agent
ocf:heartbeat:awsvip - Amazon AWS Secondary Private IP Address Resource Agent
ocf:heartbeat:azure-events - Microsoft Azure Scheduled Events monitoring agent
...
systemd:virtlockd - systemd unit file for virtlockd
systemd:virtlockd-admin.socket - systemd unit file for virtlockd-admin.socket
systemd:virtlockd.socket - systemd unit file for virtlockd.socket
systemd:virtlogd - systemd unit file for virtlogd
systemd:virtlogd-admin.socket - systemd unit file for virtlogd-admin.socket
systemd:virtlogd.socket - systemd unit file for virtlogd.socket
systemd:vmtoolsd - systemd unit file for vmtoolsd
systemd:wacom-inputattach@ - systemd unit file for wacom-inputattach@
systemd:wpa_supplicant - systemd unit file for wpa_supplicant
systemd:zram - systemd unit file for zram


## To list available resource agents

pcs resource agents


## To show possible options for a specified resource agent

pcs resource describe agent_name

e.g.

pcs resource describe apache

(sample output)
Assumed agent name 'ocf:heartbeat:apache' (deduced from 'apache')
ocf:heartbeat:apache - Manages an Apache Web server instance

This is the resource agent for the Apache Web server.
This resource agent operates both version 1.x and version 2.x Apache
servers.

The start operation ends with a loop in which monitor is
repeatedly called to make sure that the server started and that
it is operational. Hence, if the monitor operation does not
succeed within the start operation timeout, the apache resource
will end with an error status.

The monitor operation by default loads the server status page
which depends on the mod_status module and the corresponding
configuration file (usually /etc/apache2/mod_status.conf).
Make sure that the server status page works and that the access
is allowed *only* from localhost (address 127.0.0.1).
See the statusurl and testregex attributes for more details.

See also http://httpd.apache.org/

Resource options:
  configfile (unique): The full pathname of the Apache configuration file. This file is parsed to provide defaults for various other
                       resource agent parameters.
  httpd: The full pathname of the httpd binary (optional).
  port: A port number that we can probe for status information using the statusurl. This will default to the port number found in the
        configuration file, or 80, if none can be found in the configuration file.
  statusurl: The URL to monitor (the apache server status page by default). If left unspecified, it will be inferred from the apache
             configuration file. If you set this, make sure that it succeeds *only* from the localhost (127.0.0.1). Otherwise, it may
             happen that the cluster complains about the resource being active on multiple nodes.
  testregex: Regular expression to match in the output of statusurl. Case insensitive.
  client: Client to use to query to Apache. If not specified, the RA will try to find one on the system. Currently, wget and curl are
          supported. For example, you can set this parameter to "curl" if you prefer that to wget.
  testurl: URL to test. If it does not start with "http", then it's considered to be relative to the Listen address.
  testregex10: Regular expression to match in the output of testurl. Case insensitive.
  testconffile: A file which contains test configuration. Could be useful if you have to check more than one web application or in
                case sensitive info should be passed as arguments (passwords). Furthermore, using a config file is the only way to
                specify certain parameters. Please see README.webapps for examples and file description.
  testname: Name of the test within the test configuration file.
  options: Extra options to apply when starting apache. See man httpd(8).
  envfiles: Files (one or more) which contain extra environment variables. If you want to prevent script from reading the default
            file, set this parameter to empty string.
  use_ipv6: We will try to detect if the URL (for monitor) is IPv6, but if that doesn't work set this to true to enforce IPv6.

Default operations:
  start: interval=0s timeout=40s
  stop: interval=0s timeout=60s
  monitor: interval=10s timeout=20s


## To create Filesystem resource
## e.g. for lvm volume /dev/mapper/vg_data/lv_data mounted on /var/www of type ext4

pcs resource create httpd_fs Filesystem device="/dev/mapper/vg_data-lv_data" directory="/var/www" fstype="ext4" --group apache


## To create Virtual IP (VIP) resource
## e.g.

pcs resource create httpd_vip IPaddr2 ip=172.24.11.13 cidr_netmask=24 --group apache


## To create apache service resource

pcs resource create httpd_svc apache configfile="/etc/httpd/conf/httpd.conf" statusurl="http://127.0.0.1/server-status" --group apache


## To bring a node offline

pcs node standby nodename


## To bring a node make online from offline

pcs node unstandby nodename