Clustered services consist of one or more resources. A resource can be an IP address, a file system, or a service like httpd, among others. All the bits required to provide a service to consumers are a resource.
With the Red Hat High Availability Add-on, all resources are monitored independently from each other. In order to accomplish this, resources are controlled by resource agents. Pacemaker can manage different kinds of resource agents:
|LSB||Linux Standard Base-compatible init scripts residing in /etc/ init.d/.|
|OCF||Open Cluster Framework-compatible scripts that are extended LSB init scripts that can process additional input parameters to provide additional control over the cluster resource.|
|Systemd||Systemd unit files, which are the standard for defining and managing services on Red Hat Enterprise Linux 7.|
Commonly used resources
The following table has a list of some commonly used resources:
|Filesystem||Used for mounting a file system. This can be a local file system, a file system on a iSCSI or Fibre Channel device, or a remote file system like a NFS export or an SMB share.|
|IPaddr2||This resource is used to assign a floating IP address to a resource group. There is also a separate IPaddr resource that uses an older method of assigning a IP address. On Red Hat Enterprise Linux 7 IPaddr is a symbolic link to IPaddr2.|
|apache||This resource starts an apache httpd service. Unless otherwise configured this will use the configuration from /etc/httpd.|
|mysql||This resource controls a mysql database. Databases can be configured for standalone operation, a clone set with external replication, or as a full master/slave setup.|
A service usually consists of more than one resource. As an example, a typical web service consists of an IP address resource, an Apache resource, and a shared file system resource for the Document Root of the web server. All web service resources need to run on the same cluster node to provide a working service. A convenient way to tie those resources together is to add them to the same resource group. All services in the same resource group get started in the order in which they have been added to the resource group and stopped in the reverse order. When a cluster node fails, the cluster migrates the whole resource group to a different node and starts the resources on the new node.
Configuring cluster resources
The Red Hat High Availability Add-on offers a wide range of support for cluster resources. Cluster resources are managed by scripts called agents. The agents are required to start. stop, and monitor the configured cluster resources.
Display resource agents
It is important for a cluster administrator to get an overview of all available resource agents provided by the Red Hat High Availability Add-on. The command pcs resource list lists all resource agents known to Pacemaker.
# pcs resource list ocf:heartbeat:CTDB - CTDB Resource Agent ocf: heartbeat: Delay - Waits for a defined timespan ocf:heartbeat:Dummy - Example stateless resource agent ocf:heartbeat:Filesystem - Manages filesystem mounts ...
Display resource agent parameters
Every resource agent offers a list of tunable parameters. The command pcs resource describe resource_name displays a description and a list of tunable parameters for a given cluster resource. To show information and parameters of the Filesystem resource, execute:
# pcs resource describe Filesystem ocf:heartbeat:Filesystem - Manages filesystem mounts ... Resource options: device (required): The name of block device for the filesystem, or -U, -L options for mount, or NFS mount specification. directory (required): The mount point for the filesystem. fstype (required): The type of filesystem to be mounted. options: Any extra options to be given as -o options to mount. For bind mounts, add "bind" here and set fstype to "none". we will do the right thing for options such as "bind,ro". ...
Create cluster resources
When creating a cluster resource, it can be instantly added to a resource group with pcs resource create resource_name resource_provider resource parameters –group group_name. If the group provided with the –group option does not exist, it is automatically created. If the resource group already exists, the resource is added as the last item to the existing group. The – -group option may be omitted to create a standalone resource that is not part of any resource group. To create the myfs resource using the Filesystem resource agent that uses the XFS-formatted /dev/sdb1 device mounted on /var/www/html as part of the mygroup resource group, execute:
# pcs resource create myfs Filesystem device=/dev/sdb1 directory=/var/www/ html fstype=xfs --group mygroup
Display configured cluster resources
An overview of configured cluster resources and resource groups is viewable with the pcs resource show command, along with the resource status:
# pcs resource show Resource Group: mygroup myip ( ocf::heartbeat:IPaddr2): started myfs ( ocf::heartbeat:Filesystem): started myserv (ocf::heartbeat:apache): started
The pcs resource show command, followed by a defined cluster resource as a parameter, shows details about the configured resource, such as the resource attributes and operation settings:
# pcs resource show myfs Resource: myfs (class=ocf provider=heartbeat type=Filesystem) Attributes: device=/dev/sdbl directory=/var/www/html fstype=xfs Operations: start interval=0s timeout=60 (myfs-start-timeout-60) stop interval=0s timeout=60 '(myfs-stop-timeout-60) monitor interval=20 timeout=40 (myfs-monitor-interval-20)
Change resource parameter
At times, there might be a desire to fine-tune an already created cluster resource or to change options to refine the existing configuration. The Red Hat High Availability Add-on allows for changing cluster resource configurations with the pcs resource update command. To change the device of the cluster resource myfs to use /dev/sda1 as the device, execute:
# pcs resource update myfs device=/dev/sda1
Remove cluster resources
Cluster resources and resource group configurations may be removed from the cluster if they are not required any more. The pcs resource delete name allows for deleting single resources, as well as resource groups with all resources that are attached to it.
# pcs resource delete myfs
How to Create and Configure Resource Groups in a Pacemaker Cluster