• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Create and Configure Resource Groups in a Pacemaker Cluster

By admin

Configuring resource groups

In most cases, having the cluster run individual resources is not an ideal situation. Mounting a file system with web content on one node, starting an httpd instance on a second, and assigning a floating IP address to a third node does not create a service that consumers can use.

Resources can be combined into resource groups that will force all resources in a group to start and stop at the same time, on the same node, creating clustered services for consumers.

Creating a clustered Apache service

For a clustered Apache web server, a minimum of three different resources are required:

  1. A (floating) IP address resource with an IP address from the public network to access the content served by the Apache web server.
  2. A filesystem resource that provides the content to be served by the Apache web server. (In theory, it is also possible to have all web content on all nodes, but this requires a mechanism to sync the content.)
  3. An apache resource controlling the httpd system service.

The first step toward a clustered web service is to define an IP address resource. In order to create the cluster resource called webip, using the resource agent IPaddr2 with the floating IP address 172. 25. 99. 80/24 as part of the myweb resource group, execute:

# pcs resource create webip IPaddr2 ip=172.25.99.88 cidr_netmask=24 --group myweb
Note: The Red Hat High Availability Add-on ships with two IP address resources: IPaddr and IPaddr2. In releases prior to Red Hat Enterprise Linux 7, IPaddr uses the net-tools infrastructure, such as the ifconfig command. In Red Hat Enterprise Linux 7, IPaddr is a symlink to IPaddr2, which uses the ip command to manage floating IP addresses.

The web server will also need access to shared storage hosting the content for the web server. In order to create a Filesystem resource for a NFS mount workstation.storage1.example.com: /exports/www on /var/www, execute:

# pcs resource create webfs Filesystem \
>	device=workstation.storage1.example.com:/exports/www \
> 	directory=/var/www \
>   fstype=nfs \
>	options=ro \
>   --group myweb
Note: With SELinux enabled on the cluster nodes, the cluster administrator must ensure that the content of any mounted file system can be used by the relevant daemons. For a block device, this can entail setting proper SELinux contexts; for NFS, this will mean setting the relevant SELinux Booleans, such as httpd_use_nfs=1.

The myweb resource group requires an Apache resource for sharing the document root content. For that, the httpd package needs to be installed and firewalld needs to allow access to the relevant ports on each cluster node the service can migrate to.

The cluster script can monitor the availability of the web server by periodically monitoring a status URL. For the monitoring to operate, the wget package must be installed on all cluster nodes that will serve the monitored Apache web server. The status URL must only be available from 127.0.0.1. To create the required status URL, the following section must be present in the httpd configuration. Using a separate file in /etc/httpd/conf.d is recommended.

<Location /server-status>
SetHandler server-status 
Require ip 127.0.0.1 
Require all denied 
</Location>

Other URLs can also be specified; for example, a main page or internal status page of the web application being hosted can be used to verify availability.

The resource called webserver using the apache resource agent can then be created and added to the myweb resource group with the httpd configuration file /etc/httpd/conf/httpd.conf and the status URL http://127.0.0.1/server-status, which adds monitoring to the resource.

# pcs resource create webserver apache \
>	configfile="/etc/httpd/conf/httpd.conf" \
>   statusurl="http://127.8.8.1/server-status" --group myweb

Tune resource operations

Every cluster resource has three operations: start, stop, and monitor.

 pcs resource show webserver 
Resource: webserver (class=ocf provider=heartbeat type=apache) 
Attributes: configfile=/etc/httpd/conf/httpd.conf statusurl=http://127.0.0.1/server­-status 
Operations: start interval=0s timeout=60 (apachefs-start-timeout-60) 
            stop interval=0s timeout=60 (apachefs-stop-timeout-60) 
            monitor interval=20 timeout=40 (apachefs-monitor-interval-20)

Operation parameters can be tuned by a system administrator when creating a resource by adding op operation, followed by one or more operation options:

interval=value

Defines the time between the monitoring checks. The default value is taken from the resource agent. If the resource agent does not provide a default, the value is set to 60s.

timeout=value

Defines the amount of time to wait before an operation is declared as failed if it did not complete until a timeout is reached.

on-fail=action

The action to take if the operation failed:

  • ignore ignores any failure of the operation.
  • block stops performing any operations. This is the default action for a failed stop operation if the cluster does not have fencing configured.
  • stop stops the resource from being active in the cluster. This is the default action for a failure of the start and monitor operations.
  • restart stops and starts the resource.
  • fence fences the node on which the resource failed. This is the default action for a failed stop operation for a cluster with fencing configured.
  • standby moves all resources away from the cluster node the resource was running on.

To create the webserver resource with a monitoring interval of 20 seconds with a timeout of 30 seconds.execute:

# pcs resource create webserver apache \
>	configfile="/etc/httpd/conf/httpd.conf" \
>	statusurl=0http://127.8.8.1/server-status" --group myweb \
>   op monitor interval=28s timeout=30s

Resource operations can be added and removed with the pcs resource op add and pcs resource op remove commands, respectively. To remove the existing monitoring operation from the webserver resource, execute:

# pcs resource op remove webserver monitor

For setting new parameters for the monitoring operation of the webserver resource with an monitoring interval of 10 seconds and a monitoring timeout of 15 seconds, resulting in a fenced node if the monitoring operation fails, execute:

# pcs resource op add webserver monitor interval=10s timeout=15s on­fail=fence
Note: If a resource fails to start. the resource failcount will be set to INFINITY, which prevents the resource from starting on the node forever. Existing failcounts can be displayed with pcs resource failcount show. To troubleshoot the cause of failure, it is valuable to take a look at the output of pcs resource debug-start name, which displays the error messages of the resource start attempt, and then repairs the issue. Once repaired, the failcount of the resource has to be reset for the resource to be allowed to start again on that node with: pcs resource failcount reset resourcename node.

Add and remove resources from a resource group

An existing resource can be added to a resource group. For that. the cluster administrator has to execute pcs resource group add groupname name. If the resource is already a member of a group, it will be removed from the group and then added to the group specified on the command line. If the target resource group does not exist, it gets automatically created. To add the resource myresource to the mygroup resource group, execute:

# pcs resource group add mygroup myresource

A resource that is part of a resource group may be removed from the resource group with pcs resource group remove groupname name. The resource then still exists in the cluster, but is not part of the resource group any more. If the last resource is removed from the resource group, the resource group is removed as well. To remove the myresource resource from the mygroup resource group, execute:

# pcs resource group remove mygroup myresource

Resource ordering

In some cases, there might be a dependency between resources added to a group. For example, a web server configured to listen on a specific IP address won’t be able to start until that IP address is configured on a node. Normally resources will be started in the order that they are added to a group, and stopped in reverse order.

To influence the ordering, the options –before resourceid and –after resourceid can be added to pcs resource create and pcs resource group add to influence the ordering in which resources will be started.

Managing resources in a pacemaker cluster (stop/start and relocate resource groups in a running cluster)
How to Create and Configure Resources in a Pacemaker Cluster
Beginner Guide to RHEL 7 high-availability cluster – Architectural Overview

Filed Under: pacemaker

Some more articles you might also be interested in …

  1. How to Configure Multiple Fencing-device Levels in Pacemaker Cluster
  2. What is quorum in a pacemaker cluster (Understanding Quorum Operations)
  3. How To Change Pacemaker Cluster Heartbeat Timeout In CentOS/RHEL 7
  4. How to Create a GFS2 Formatted Cluster File System
  5. Troubleshooting Pacemaker Cluster Networking
  6. Beginner Guide to RHEL 7 high-availability cluster – Architectural Overview
  7. Most Common Two-node Pacemaker cluster issues and their workarounds
  8. How to Configure Pacemaker Cluster Notifications
  9. Managing Cluster Membership in pacemaker cluster (Adding and removing a cluster node)
  10. How to Create and Configure Resources in a Pacemaker Cluster

You May Also Like

Primary Sidebar

Recent Posts

  • What are different Oracle Database Vault Roles
  • Unable to export realm protected table using data pump
  • Beginners Guide to Oracle Database Vault
  • How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary