Chapter 46. Getting started with Pacemaker
To familiarize yourself with the tools and processes you use to create a Pacemaker cluster, you can run the following procedures. They are intended for users who are interested in seeing what the cluster software looks like and how it is administered, without needing to configure a working cluster.
These procedures do not create a supported Red Hat cluster, which requires at least two nodes and the configuration of a fencing device. For full information about Red Hat’s support policies, requirements, and limitations for RHEL High Availability clusters, see Support Policies for RHEL High Availability Clusters.
46.1. Learning to use Pacemaker Copy linkLink copied to clipboard!
By working through this procedure, you will learn how to use Pacemaker to set up a cluster, how to display cluster status, and how to configure a cluster service. This example creates an Apache HTTP server as a cluster resource and shows how the cluster responds when the resource fails.
In this example:
-
The node is
z1.example.com
. - The floating IP address is 192.168.122.120.
Prerequisites
- A single node running RHEL 8
- A floating IP address that resides on the same network as one of the node’s statically assigned IP addresses
-
The name of the node on which you are running is in your
/etc/hosts
file
Procedure
Install the Red Hat High Availability Add-On software packages from the High Availability channel, and start and enable the
pcsd
service.yum install pcs pacemaker fence-agents-all systemctl start pcsd.service systemctl enable pcsd.service
# yum install pcs pacemaker fence-agents-all ... # systemctl start pcsd.service # systemctl enable pcsd.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you are running the
firewalld
daemon, enable the ports that are required by the Red Hat High Availability Add-On.firewall-cmd --permanent --add-service=high-availability firewall-cmd --reload
# firewall-cmd --permanent --add-service=high-availability # firewall-cmd --reload
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set a password for user
hacluster
on each node in the cluster and authenticate userhacluster
for each node in the cluster on the node from which you will be running thepcs
commands. This example is using only a single node, the node from which you are running the commands, but this step is included here since it is a necessary step in configuring a supported Red Hat High Availability multi-node cluster.passwd hacluster pcs host auth z1.example.com
# passwd hacluster ... # pcs host auth z1.example.com
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a cluster named
my_cluster
with one member and check the status of the cluster. This command creates and starts the cluster in one step.Copy to Clipboard Copied! Toggle word wrap Toggle overflow A Red Hat High Availability cluster requires that you configure fencing for the cluster. The reasons for this requirement are described in the Red Hat Knowledgebase solution Fencing in a Red Hat High Availability Cluster. For this introduction, however, which is intended to show only how to use the basic Pacemaker commands, disable fencing by setting the
stonith-enabled
cluster option tofalse
.WarningThe use of
stonith-enabled=false
is completely inappropriate for a production cluster. It tells the cluster to simply pretend that failed nodes are safely fenced.pcs property set stonith-enabled=false
# pcs property set stonith-enabled=false
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure a web browser on your system and create a web page to display a simple text message. If you are running the
firewalld
daemon, enable the ports that are required byhttpd
.NoteDo not use
systemctl enable
to enable any services that will be managed by the cluster to start at system boot.Copy to Clipboard Copied! Toggle word wrap Toggle overflow In order for the Apache resource agent to get the status of Apache, create the following addition to the existing configuration to enable the status server URL.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create
IPaddr2
andapache
resources for the cluster to manage. TheIPaddr2
resource is a floating IP address that must not be one already associated with a physical node. If theIPaddr2
resource’s NIC device is not specified, the floating IP must reside on the same network as the statically assigned IP address used by the node.You can display a list of all available resource types with the
pcs resource list
command. You can use thepcs resource describe resourcetype
command to display the parameters you can set for the specified resource type. For example, the following command displays the parameters you can set for a resource of typeapache
:pcs resource describe apache
# pcs resource describe apache ...
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this example, the IP address resource and the apache resource are both configured as part of a group named
apachegroup
, which ensures that the resources are kept together to run on the same node when you are configuring a working multi-node cluster.Copy to Clipboard Copied! Toggle word wrap Toggle overflow After you have configured a cluster resource, you can use the
pcs resource config
command to display the options that are configured for that resource.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Point your browser to the website you created using the floating IP address you configured. This should display the text message you defined.
Stop the apache web service and check the cluster status. Using
killall -9
simulates an application-level crash.killall -9 httpd
# killall -9 httpd
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the cluster status. You should see that stopping the web service caused a failed action, but that the cluster software restarted the service and you should still be able to access the website.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can clear the failure status on the resource that failed once the service is up and running again and the failed action notice will no longer appear when you view the cluster status.
pcs resource cleanup WebSite
# pcs resource cleanup WebSite
Copy to Clipboard Copied! Toggle word wrap Toggle overflow When you are finished looking at the cluster and the cluster status, stop the cluster services on the node. Even though you have only started services on one node for this introduction, the
--all
parameter is included since it would stop cluster services on all nodes on an actual multi-node cluster.pcs cluster stop --all
# pcs cluster stop --all
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
46.2. Learning to configure failover Copy linkLink copied to clipboard!
The following procedure provides an introduction to creating a Pacemaker cluster running a service that will fail over from one node to another when the node on which the service is running becomes unavailable. By working through this procedure, you can learn how to create a service in a two-node cluster and you can then observe what happens to that service when it fails on the node on which it running.
This example procedure configures a two-node Pacemaker cluster running an Apache HTTP server. You can then stop the Apache service on one node to see how the service remains available.
In this example:
-
The nodes are
z1.example.com
andz2.example.com
. - The floating IP address is 192.168.122.120.
Prerequisites
- Two nodes running RHEL 8 that can communicate with each other
- A floating IP address that resides on the same network as one of the node’s statically assigned IP addresses
-
The name of the node on which you are running is in your
/etc/hosts
file
Procedure
On both nodes, install the Red Hat High Availability Add-On software packages from the High Availability channel, and start and enable the
pcsd
service.yum install pcs pacemaker fence-agents-all systemctl start pcsd.service systemctl enable pcsd.service
# yum install pcs pacemaker fence-agents-all ... # systemctl start pcsd.service # systemctl enable pcsd.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you are running the
firewalld
daemon, on both nodes enable the ports that are required by the Red Hat High Availability Add-On.firewall-cmd --permanent --add-service=high-availability firewall-cmd --reload
# firewall-cmd --permanent --add-service=high-availability # firewall-cmd --reload
Copy to Clipboard Copied! Toggle word wrap Toggle overflow On both nodes in the cluster, set a password for user
hacluster
.passwd hacluster
# passwd hacluster
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Authenticate user
hacluster
for each node in the cluster on the node from which you will be running thepcs
commands.pcs host auth z1.example.com z2.example.com
# pcs host auth z1.example.com z2.example.com
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a cluster named
my_cluster
with both nodes as cluster members. This command creates and starts the cluster in one step. You only need to run this from one node in the cluster becausepcs
configuration commands take effect for the entire cluster.On one node in cluster, run the following command.
pcs cluster setup my_cluster --start z1.example.com z2.example.com
# pcs cluster setup my_cluster --start z1.example.com z2.example.com
Copy to Clipboard Copied! Toggle word wrap Toggle overflow A Red Hat High Availability cluster requires that you configure fencing for the cluster. The reasons for this requirement are described in the Red Hat Knowledgebase solution Fencing in a Red Hat High Availability Cluster. For this introduction, however, to show only how failover works in this configuration, disable fencing by setting the
stonith-enabled
cluster option tofalse
.WarningThe use of
stonith-enabled=false
is completely inappropriate for a production cluster. It tells the cluster to simply pretend that failed nodes are safely fenced.pcs property set stonith-enabled=false
# pcs property set stonith-enabled=false
Copy to Clipboard Copied! Toggle word wrap Toggle overflow After creating a cluster and disabling fencing, check the status of the cluster.
NoteWhen you run the
pcs cluster status
command, it may show output that temporarily differs slightly from the examples as the system components start up.Copy to Clipboard Copied! Toggle word wrap Toggle overflow On both nodes, configure a web browser and create a web page to display a simple text message. If you are running the
firewalld
daemon, enable the ports that are required byhttpd
.NoteDo not use
systemctl enable
to enable any services that will be managed by the cluster to start at system boot.Copy to Clipboard Copied! Toggle word wrap Toggle overflow In order for the Apache resource agent to get the status of Apache, on each node in the cluster create the following addition to the existing configuration to enable the status server URL.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create
IPaddr2
andapache
resources for the cluster to manage. TheIPaddr2
resource is a floating IP address that must not be one already associated with a physical node. If theIPaddr2
resource’s NIC device is not specified, the floating IP must reside on the same network as the statically assigned IP address used by the node.You can display a list of all available resource types with the
pcs resource list
command. You can use thepcs resource describe resourcetype
command to display the parameters you can set for the specified resource type. For example, the following command displays the parameters you can set for a resource of typeapache
:pcs resource describe apache
# pcs resource describe apache ...
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this example, the IP address resource and the apache resource are both configured as part of a group named
apachegroup
, which ensures that the resources are kept together to run on the same node.Run the following commands from one node in the cluster:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note that in this instance, the
apachegroup
service is running on node z1.example.com.Access the website you created, stop the service on the node on which it is running, and note how the service fails over to the second node.
- Point a browser to the website you created using the floating IP address you configured. This should display the text message you defined, displaying the name of the node on which the website is running.
Stop the apache web service. Using
killall -9
simulates an application-level crash.killall -9 httpd
# killall -9 httpd
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the cluster status. You should see that stopping the web service caused a failed action, but that the cluster software restarted the service on the node on which it had been running and you should still be able to access the web browser.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Clear the failure status once the service is up and running again.
pcs resource cleanup WebSite
# pcs resource cleanup WebSite
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Put the node on which the service is running into standby mode. Note that since we have disabled fencing we can not effectively simulate a node-level failure (such as pulling a power cable) because fencing is required for the cluster to recover from such situations.
pcs node standby z1.example.com
# pcs node standby z1.example.com
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the status of the cluster and note where the service is now running.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Access the website. There should be no loss of service, although the display message should indicate the node on which the service is now running.
To restore cluster services to the first node, take the node out of standby mode. This will not necessarily move the service back to that node.
pcs node unstandby z1.example.com
# pcs node unstandby z1.example.com
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For final cleanup, stop the cluster services on both nodes.
pcs cluster stop --all
# pcs cluster stop --all
Copy to Clipboard Copied! Toggle word wrap Toggle overflow