Linux

How to Install Pacemaker on Linux Quick Start Tutorial

When managing our server cluster at IOFLOOD, we installed the Linux Pacemaker tool to assess its cluster management capabilities. We’ve shared our best installation methods in this article to help you properly install Pacemaker for high availability and failover protection on your custom server configurations.

In this Pacemaker tutorial, we’ll guide you through the process of installing Pacemaker on your Linux system. We’ll cover methods for both APT and YUM-based distributions, delve into compiling Pacemaker from source, installing a specific version, and finally, how to use Pacemaker and verify its installation.

So, let’s dive in and start installing Pacemaker on your Linux system!

TL;DR: How Do I Install Corosync Pacemaker on Linux?
Pacemaker can be installed on CentOS with the command sudo yum install pacemaker corosync. To start the service, enable it with systemctl enable pacemaker corosync and start it with systemctl start pacemaker corosync. On Ubuntu, you can use the following command:

1. sudo apt-get update
2. sudo apt-get install pacemaker corosync
3. sudo systemctl enable pacemaker corosync
4. sudo systemctl start pacemaker corosync

This command will retrieve the Pacemaker package from the Ubuntu repositories and install it on your system. However, this is just the basic method for installing Pacemaker on Linux. There is much more to learn about the installation process, including how to compile from source, install a specific version, and verify the installation. Continue reading for more detailed information and advanced installation options.

Getting Started: Install Pacemaker

Pacemaker is a high-availability cluster resource manager that ensures your services, such as a web server or database, continue running even in the event of system failures. It achieves this by creating a cluster of systems and managing the services across them. If a service fails on one system, Pacemaker can automatically relocate it to another system within the cluster.

Now, let’s get into the installation process. We’ll cover how to install Pacemaker using package managers like APT (for Debian and Ubuntu) and YUM (for CentOS and AlmaLinux).

Install Pacemaker with APT

 

If you’re using a Debian or Ubuntu system, you can install Pacemaker using the APT package manager. Here’s how:

sudo apt update
sudo apt install pacemaker corosync

Reading package lists… Done
Building dependency tree… Done
The following additional packages will be installed:…
Do you want to continue? [Y/n]
After running these commands, your system will fetch the latest software list, then download and install the Pacemaker package.

Install Pacemaker with YUM

For those using CentOS or AlmaLinux, the YUM package manager is the option for installing Pacemaker. Here’s the command sequence:

sudo yum check-update
sudo yum install pacemaker corosync

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
Dependencies Resolved
This will update your package list and then install Pacemaker on your system.

Remember, these are the basic installation methods. There are more advanced methods, like compiling from source or installing specific versions, which we’ll discuss in the next section.

Install Pacemaker from Source

While installing Pacemaker using package managers like APT or YUM is convenient, you might need to install it from source in some cases. This could be necessary if you need a specific version not available in your distribution’s repository or if you want to customize the build.

Pacemaker Installation from Source Code
To install Pacemaker from source, first download the source code from the official Pacemaker GitHub repository. Here’s how:

git clone https://github.com/ClusterLabs/pacemaker.git

Cloning into ‘pacemaker’…
remote: Enumerating objects: 762, done.
remote: Counting objects: 100% (762/762), done.
remote: Compressing objects: 100% (500/500), done.
This command clones the Pacemaker repository into a new directory named ‘pacemaker’.

Next, navigate to the ‘pacemaker’ directory and compile the source code:

cd pacemaker
./autogen.sh && ./configure && make

Generating build system
Configuring pacemaker
Building pacemaker
This will generate the build system, configure it, and then compile the Pacemaker source code.

Specific Versions: Install Pacemaker

There are situations where you might need to install a specific version of Pacemaker, either due to compatibility requirements, desired features, or stability concerns.

Installing a Specific Version from Source

 

When installing from source, you can check out a specific version before building. Here’s how:

git checkout tags/Pacemaker-2.0.5
./autogen.sh && ./configure && make

Checking out Pacemaker 2.0.5
Generating build system
Configuring pacemaker
Building pacemaker
This command checks out Pacemaker version 2.0.5 and then builds it.

Installing a Specific Version with APT and YUM

You can also install a specific version of Pacemaker using APT or YUM. Here’s how:

For APT:

sudo apt-get install pacemaker=2.0.5-3

For YUM:

sudo yum install pacemaker-2.0.5-3

Reading package lists… Done
Building dependency tree… Done
The following additional packages will be installed:…
Do you want to continue? [Y/n]
These commands will install Pacemaker version 2.0.5-3 on your system.

Pacemaker Version Comparison

Different versions of Pacemaker offer varying features and compatibility. Here’s a brief comparison:

Version Key Features Compatibility
2.0.5 Improved fencing mechanism, Enhanced resource management Linux Kernel 3.10 and above
2.0.3 Improved resource management, Bug fixes Linux Kernel 3.10 and above
1.1.23 Stable, Fewer features Linux Kernel 2.6.32 and above
Use and Verify Corosync Pacemaker
Once Pacemaker is installed, you can verify the installation by checking the version:

pacemakerd –version

Pacemaker 2.0.5
This command will display the installed Pacemaker version.

To start using Pacemaker, start the service with:

sudo systemctl start pacemaker

This command starts the Pacemaker service. You can then use crm_mon to monitor your Pacemaker cluster:

crm_mon

No cluster configured
This command displays the status of your Pacemaker cluster. Since a cluster has not been set up yet, it shows ‘No cluster configured’.

Alternatives to Linux Pacemaker

While Pacemaker is a powerful tool for managing high-availability clusters, there are other solutions that might suit your needs better. Two notable alternatives are Corosync and Keepalived.

Corosync Cluster Engine

Corosync is a group communication system that offers reliable and ordered message delivery. It serves as the default messaging layer for Pacemaker but can also be used independently for high-availability clustering.

To install Corosync on Ubuntu, use the following command:

sudo apt-get install corosync

Reading package lists… Done
Building dependency tree… Done
The following additional packages will be installed:…
Do you want to continue? [Y/n]
Corosync provides efficient messaging and a flexible communication layer for cluster management. It is compatible with various cluster resource managers like Pacemaker.

Keepalived for Linux

Keepalived is another alternative that utilizes the VRRP (Virtual Router Redundancy Protocol) to provide failover capabilities.

To install Keepalived on CentOS, use the following command:

sudo yum install keepalived

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
Dependencies Resolved

Keepalived is relatively easy to configure and use, making it a suitable option for beginners. It also supports load balancing through the LVS (Linux Virtual Server) project.

Pacemaker vs. Corosync vs. Keepalived

When choosing between Pacemaker, Corosync, and Keepalived, consider your specific needs. Here’s a brief comparison:

Solution Pro Con
Pacemaker Highly configurable, Wide range of resource agents Complex configuration
Corosync Efficient messaging, Flexible Requires additional resource manager for complete HA solution
Keepalived Easy to use, Supports load balancing Limited resource types
There is no one-size-fits-all solution. While Pacemaker is highly capable, Corosync and Keepalived offer distinct features that might better match your use case. Always evaluate your requirements and the features of each tool before making a choice.

Fixing Linux Pacemaker Installs

You might encounter issues during Pacemaker installation or operation. Here are common problems and their solutions:

Issue: Pacemaker Installation Fails due to Unmet Dependencies

Sometimes, the installation fails due to unmet dependencies. The error might look like this:

sudo apt-get install pacemaker

Reading package lists… Done
Building dependency tree… Done
Some packages could not be installed…
You might want to run ‘apt –fix-broken install’…
To fix this, run:

sudo apt –fix-broken install

Reading package lists… Done
Building dependency tree… Done
Correcting dependencies… Done
This command attempts to correct broken dependencies, allowing Pacemaker to be installed successfully.

Issue: Pacemaker Service Fails to Start

If the Pacemaker service fails to start, it could be due to configuration errors or system issues. The error might appear as:

sudo systemctl start pacemaker

Job for pacemaker.service failed because the control process exited with error code.
See “systemctl status pacemaker.service” and “journalctl -xe” for details.
To diagnose the issue, check the service status:

systemctl status pacemaker.service

pacemaker.service – Pacemaker High Availability Cluster Manager
Loaded: loaded (/lib/systemd/system/pacemaker.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code)
Main PID: 12345 (code=exited, status=1/FAILURE)
This command displays the service status and error messages, which can help troubleshoot the problem.

What is a Pacemaker Cluster?

High-availability (HA) clusters are groups of computers that ensure server applications remain operational with minimal downtime. They work by using redundant systems that continue to provide service if one fails. Without clustering, a critical server failure means its services become unavailable until resolved.

Example of a Service Managed by an HA Cluster:

sudo systemctl start apache2

Starting apache2 (via systemctl): apache2.service.
In this example, the Apache2 service could be managed by an HA cluster. If the server running Apache2 fails, the service would become unavailable unless part of a high-availability cluster.

The Importance of a Pacemaker Cluster

System downtime can lead to significant financial loss and reputational damage. High-availability clusters mitigate these risks by providing continuity. If one server fails, others in the cluster can handle the workload.

The Role of Corosync Pacemaker

Pacemaker is a cluster resource manager (CRM) that ensures high availability by detecting and recovering from node failures. It moves resources from failed nodes to healthy ones.

Example of a Resource Managed by Pacemaker:

crm configure primitive ClusterIP ocf:heartbeat:IPaddr2 params ip=192.168.1.120 cidr_netmask=24 op monitor interval=30s

+ primitive ClusterIP IPaddr2 params ip=192.168.1.120 cidr_netmask=24 op monitor interval=30s
In this example, an IP address is configured as a cluster resource. Pacemaker monitors this IP address and moves it to a healthy node if the current one fails.

Cloud Computing and Pacemaker Clusters

High-availability clusters are essential for system administration and cloud computing. They ensure service availability even when parts of the system fail.

Example of a Cloud-Based Service Benefiting from High-Availability Clusters:

aws ec2 run-instances –image-id ami-0abcdef1234567890 –count 1 –instance-type t2.micro –key-name MyKeyPair –security-groups my-sg

An Amazon EC2 instance is launched

In this example, launching an Amazon EC2 instance is a cloud-based service that benefits from high-availability clustering. If the instance fails, any services running on it would become unavailable unless it is part of a high-availability cluster.

Exploring Beyond Linux Pacemaker

High-availability is one aspect of a robust system. Load balancing and failover are related concepts:

Load Balancing: Distributes network traffic across multiple servers to prevent overloading any single server, improving responsiveness and application availability.

Failover: A backup mode where functions of a system component are assumed by secondary components when the primary one fails.

Understanding these concepts together provides a comprehensive view of designing reliable systems.

 

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button