Create a Pacemaker Cluster Resources and Resources group

In our previous articles, we have seen how to set up a Pacemaker Linux cluster. Now let’s start to create a Pacemaker cluster Resources and Resource Group in our cluster.

Introduction to Pacemaker Cluster Resources

What is Pacemaker Resources in a Cluster

Pacemaker Resources can be anything like IP address, filesystem, database, services or an entire Virtual Machines. For instance, you need to create and mount a filesystem what you will do? first, you will create a directory then create a filesystem, finally, you will mount it under the created directory (mount point). Each step what we have mentioned will be a resource. In the cluster, if you need to use a filesystem, mount a filesystem each will be a resource. Hope we are clear now.

The resources are controlled by agents, agents are just a script. By default installation, we will get the below type of resource agents.

Resource Type Description
LSB Resource Agents LSB resource agents are provided by Operating systems and they will resides under /etc/init.d. Most of these agents are broken so its better to create our own init script as per application requirement.
OCF Resource Agents OCF Resource agnets or Open Cluster Framework (OCF) are found under /usr/lib/ocf/resource.d/ they are implemented in a shell script.
Services & Systemd Services & Systemd are defined to manage the services.

Listing all Pacemaker Resources Agents

Let us check the resources by printing all available agents.

# pcs resource standards
# pcs resource providers
[root@corcls1 ~]# pcs resource standards
lsb
ocf
service
systemd
[root@corcls1 ~]#
[root@corcls1 ~]# pcs resource providers
heartbeat
openstack
pacemaker
[root@corcls1 ~]#

To list all available resource agents with description.

# pcs resource list

Print only the available resource without description

# pcs resource agents

Or list the specific available resources

# pcs resource list LVM

To know more information about each resource agent we can run describe option with each agent.

# pcs resource describe lsb:network
[root@corcls1 ~]# pcs resource describe lsb:network
lsb:network - Bring up/down networking

Bring up/down networking

Default operations:
  start: interval=0s timeout=15
  stop: interval=0s timeout=15
  restart: interval=0s timeout=15
  force-reload: interval=0s timeout=15
  monitor: interval=15 timeout=15
[root@corcls1 ~]#

If you are interested to write your own agent have a look into below.

[root@corcls1 ~]# ls -lthr /usr/share/resource-agents/ocft/configs
 total 144K
 -rw-r--r--. 1 root root 1.8K Jul 29 21:30 tomcat
 -rw-r--r--. 1 root root 5.1K Jul 29 21:30 sg_persist
 -rw-r--r--. 1 root root 2.5K Jul 29 21:30 postfix
 -rw-r--r--. 1 root root 1.4K Jul 29 21:30 portblock
 -rw-r--r--. 1 root root 1.4K Jul 29 21:30 pgsql
 -rw-r--r--. 1 root root 1.6K Jul 29 21:30 oracle
 -rw-r--r--. 1 root root 1.4K Jul 29 21:30 nfsserver
 -rw-r--r--. 1 root root 1.5K Jul 29 21:30 named
 -rw-r--r--. 1 root root 2.0K Jul 29 21:30 mysql-proxy
 -rw-r--r--. 1 root root 1.6K Jul 29 21:30 mysql
 -rw-r--r--. 1 root root 2.0K Jul 29 21:30 jboss
 -rw-r--r--. 1 root root 2.6K Jul 29 21:30 iscsi
 -rw-r--r--. 1 root root 1.5K Jul 29 21:30 exportfs-multidir
 -rw-r--r--. 1 root root 1.6K Jul 29 21:30 exportfs
 -rw-r--r--. 1 root root 3.7K Jul 29 21:30 drbd.linbit
 -rw-r--r--. 1 root root 4.7K Jul 29 21:30 db2
 -rw-r--r--. 1 root root 1.4K Jul 29 21:30 apache
 -rw-r--r--. 1 root root 1.3K Jul 29 21:30 Xinetd
 -rw-r--r--. 1 root root 1.3K Jul 29 21:30 Xen
 -rw-r--r--. 1 root root 1.5K Jul 29 21:30 VirtualDomain
 -rw-r--r--. 1 root root 1.5K Jul 29 21:30 SendArp
 -rw-r--r--. 1 root root 3.4K Jul 29 21:30 Raid1
 -rw-r--r--. 1 root root 1.1K Jul 29 21:30 MailTo
 -rw-r--r--. 1 root root 1.7K Jul 29 21:30 LVM
 -rw-r--r--. 1 root root 4.3K Jul 29 21:30 IPv6addr
 -rw-r--r--. 1 root root 1.3K Jul 29 21:30 IPsrcaddr
 -rw-r--r--. 1 root root 6.2K Jul 29 21:30 IPaddr2v6
 -rw-r--r--. 1 root root 9.6K Jul 29 21:30 IPaddr2v4
 -rw-r--r--. 1 root root 3.5K Jul 29 21:30 IPaddr2
 -rw-r--r--. 1 root root 2.2K Jul 29 21:30 Filesystem
 [root@corcls1 ~]#

Creating a Resource

Create a resource using pcs command with create option and arguments. Once the resource created print it using show option.

# pcs resource create web-vip ocf:heartbeat:IPaddr2 ip=192.168.107.225 cidr_netmask=24 op monitor interval=30s

To print, the status of the created resource

# pcs resource show
# pcs resource show web-vip
  • pcs – Control and configure pacemaker and corosync.
  • resource – Option “resource” to define any one of the resources.
  • create – To create the resource.
  • web-vip – The name of the resource we are defining.
  • ocf:heartbeat:IPaddr2 – Type of agent standard:provider:type
  • ip=192.168.107.225 – IP address to use for Virtual IP address
  • cidr_netmask=24 – Netmask for Virtual IP address.
  • op monitor – The Operation action.
  • interval=30s – Operation options need to be used.
[root@corcls1 ~]# pcs resource create web-vip ocf:heartbeat:IPaddr2 ip=192.168.107.225 cidr_netmask=24 op monitor interval=30s
[root@corcls1 ~]#

[root@corcls1 ~]# pcs resource show
  web-vip    (ocf::heartbeat:IPaddr2):   Started corcls1
[root@corcls1 ~]#

[root@corcls1 ~]# pcs resource show web-vip
  Resource: web-vip (class=ocf provider=heartbeat type=IPaddr2)
   Attributes: cidr_netmask=24 ip=192.168.107.225
   Operations: monitor interval=30s (web-vip-monitor-interval-30s)
               start interval=0s timeout=20s (web-vip-start-interval-0s)
               stop interval=0s timeout=20s (web-vip-stop-interval-0s)
[root@corcls1 ~]#
Status of Pacemaker cluster resources
Status of cluster Resources

Creating a Resource Group

The Resource group consist of more than one resource. For your understanding, you need to run apache service in your cluster. To run an apache service we know it required a web document root should be available across all the nodes in the cluster and how it needs to be mounted.

Moreover, we may have some order to mount the filesystem, start the service and much more. These all will be each resource which combined under a single group with an assigned order. Hope now you got what the use of resource group.

In the above step we created a resource, now let us create a resource group and add the web-vip resource to the new group.

# pcs resource group add web-resources-grp web-vip
# pcs resource show

That’s it we have created a resource group and added to our pacemaker cluster resources.

[root@corcls1 ~]# pcs resource show
  Resource Group: web-resources-grp
      web-vip    (ocf::heartbeat:IPaddr2):   Started corcls1
[root@corcls1 ~]#

Deleting a Resource

As we have seen how to create a pacemaker cluster resources now let’s see how to delete a resource. To delete the resource

# pcs resource delete web-vip
[root@corcls1 ~]# pcs resource delete web-vip
 Attempting to stop: web-vip… Stopped
[root@corcls1 ~]#

Removing a resource will delete the resource, group, master and clone.

We have completed with creating and removing resources and resource group in a Pacemaker Linux Cluster.

Conclusion

Pacemaker cluster resources are the one making the services highly-available throughout all the nodes in a cluster. Let us come up with the new article on clustering shortly until then subscribe to our newsletter and stay updated.

Exit mobile version