In this blog post, we will discuss the step-by-step instructions on configuring an initial cluster across two nodes that are hosted on systems with the resolvable host names node1 and node2. Each system is installed and configured by using the instructions that are provided in my prior blog post Setting Up High Availability Oracle Linux Clustering Using Pacemaker and Corosync
The cluster is configured to run a service, DBMASTER, that is included in the resource-agents package. You should have installed this package along with the pacemaker packages. This tool simply keeps track of whether the service is or is not running. Pacemaker is configured with an interval parameter that determines how long it should wait between checks to determine whether the DBMASTER process has failed.The DBMASTER process is manually stopped outside of the Pacemaker tool to simulate a failure, which is used to demonstrate how the process is restarted automatically on an alternate node.
To create the cluster:
1- Authenticate the pcs cluster configuration tool for the hacluster user on each node in your configuration by running the following command on one of the nodes that will form part of the cluster:
sudo pcs host auth node1 node2 -u hacluster
Replace node1 and node2 with the resolvable hostnames of the nodes that will form part of the cluster.
Alternately, if the node names are not resolvable, specify the IP addresses where the nodes can be accessed, as shown in the following example:
sudo pcs host auth node1 addr=192.168.5.2 node2 addr=192.168.5.3 -u hacluster
Replace addr IP addresses with the IP addresses of each of the respective hosts in the cluster.
It will prompt you to provide a password for the hacluster user. Provide the password that you set for this user when you installed and configured the Pacemaker software on each node.
2- Create the cluster by using the pcs cluster setup command. You must specify a name for the cluster and the node names and IP addresses for each node in the cluster. For example, run the following command:
sudo pcs cluster setup pacemaker1 node1 addr=192.168.5.2 node2 addr=192.168.5.3
Replace pacemaker1 with an appropriate name for the cluster.
Note that if you used the addr option to specify the IP addresses when authenticated the nodes, you do not need to specify them again when running the pcs cluster setup command.
The cluster setup process destroys any existing cluster configuration on the specified nodes and creates a configuration file for the Corosync service that is copied to each of the nodes within the cluster.
3- If you have not already started the cluster as part of the cluster setup command (You can, optionally, use the –start option when running the pcs cluster setup command to automatically start the cluster once it is created.), start the cluster on all of the nodes. To start the cluster manually, use the pcs command:
sudo pcs cluster start –all
Starting the pacemaker service from systemd is another way to start the cluster on all nodes, for example:
sudo systemctl start pacemaker.service
4- Optionally, you can enable these services to start at boot time so that if a node reboots, it automatically rejoins the cluster, for example:
sudo pcs cluster enable –all
sudo systemctl enable pacemaker.service
We configured and started the pacemaker cluster service and will continue to write about the setting cluster parameters, creating a Service and testing failover on next blog post.