
Learn how to install KVM on Fedora 41 step-by-stepâcovering prerequisites, CLI & GUI configuration, networking, performance tuning, and best practices for virtualized environments. Table of
Learn how to set up KVM high availability with Fedora and Pacemaker to ensure seamless failover and minimal downtime for your virtual machines. Step-by-step guide with CLI examples.
In todayâs fast-paced digital world, downtime is a luxury that businesses cannot afford. For mission-critical systems, high availability (HA) setups ensure that applications and virtual machines continue running smoothly, even if hardware failures occur. One effective way to achieve high availability is by leveraging KVM (Kernel-based Virtual Machine) and Pacemaker, two powerful tools in the Linux ecosystem.
In this guide, weâll show you how to set up a high availability cluster for KVM virtual machines (VMs) using Fedora and Pacemaker. Along the way, we’ll cover the essential concepts, provide detailed CLI examples, and walk you through the configuration steps. By the end, youâll have a resilient KVM-based infrastructure capable of providing continuous uptime for your virtualized workloads.
High availability (HA) refers to the design and implementation of systems that are resilient to hardware or software failures. In virtualized environments, HA is critical to ensure that virtual machines remain up and running in case of node failures, network issues, or other unforeseen problems.
KVM provides the virtualization layer, while Pacemaker is a cluster resource manager (CRM) that ensures the availability of resources like virtual machines (VMs). Pacemaker, when paired with the Corosync cluster engine, enables the automatic failover of resources to another node in the cluster, thus minimizing downtime.
KVM (Kernel-based Virtual Machine) |
KVM is a full virtualization solution for Linux that uses the hardware-assisted virtualization extensions of modern processors. It allows you to run multiple virtual machines (VMs) on a single physical machine. KVM is widely used in enterprise environments and is supported on many Linux distributions, including Fedora.
Pacemaker |
Pacemaker is an open-source cluster resource manager that enables high availability by managing resources and services within a cluster. It monitors the state of the resources and ensures that they are running on the most suitable node. If a failure occurs on one node, Pacemaker can automatically migrate resources to a healthy node.
Benefits of Combining KVM and Pacemaker |
|
|
|
Photo by admingeek from Infotechys
Before starting, ensure you have the following in place:
Hardware Requirements |
|
|
|
Software Requirements |
|
|
|
Basic Knowledge |
|
|
|
Step 1: Install KVM and Related Packages |
First, install KVM and associated tools on both nodes. On each node, run the following commands:
sudo dnf install @virtualization
sudo dnf install libvirt virt-install qemu-kvm
sudo systemctl enable --now libvirtd
Check that KVM is working by running:
sudo systemctl is-active libvirtd
Step 2: Install Pacemaker and Corosync |
Now, let’s install Pacemaker and Corosync, which are the core components for managing high availability clusters. On both nodes, run:
sudo dnf install pacemaker corosync crmsh
Enable and start Corosync and Pacemaker services:
sudo systemctl enable --now corosync
sudo systemctl enable --now pacemaker
Step 3: Verify Installation |
To ensure the services are running correctly:
sudo systemctl status corosync pacemaker
You should see that both services are active and running.
Step 1: Configure Shared Storage |
For high availability to work, the VM storage must be accessible from both nodes. We’ll use NFS as the shared storage solution. On the primary node, install NFS:
sudo dnf install nfs-utils
Create a shared directory to store your VMs:
sudo mkdir /srv/nfs/kvm
Export this directory by adding the following to /etc/exports
:
/srv/nfs/kvm *(rw,sync,no_root_squash)
Start and enable the NFS server:
sudo systemctl enable --now nfs-server && sudo exportfs -ra
On the secondary node, mount the shared directory:
sudo mount -t nfs :/srv/nfs/kvm /srv/nfs/kvm
Step 2: Configure KVM Resources in Pacemaker |
Now we will create a resource definition for the KVM virtual machines using Pacemaker. Define the virtual machine resource in Pacemaker. Use the crm
tool to manage Pacemaker resources:
sudo crm configure primitive my-vm ocf:heartbeat:VirtualDomain \
params config="/srv/nfs/kvm/my-vm.xml" \
op monitor interval="30s"
Configure Pacemaker to manage the virtual machine:
sudo crm configure colocation vm-with-node inf: my-vm master
sudo crm configure order vm-start-after-node start: my-vm master
Step 3: Enable HA for VM |
To enable automatic failover of the virtual machine, we will set the following constraints in Pacemaker:
sudo crm configure property stonith-enabled=false
sudo crm configure property no-quorum-policy=ignore
đ STONITH (Shoot the Other Node in the Head) is disabled here because we are focusing on KVM high availability rather than node fencing. You can enable STONITH for a more robust setup later. |
Once you have configured your Pacemaker cluster with KVM, itâs time to test the failover functionality. Start the VM on the primary node:
sudo virsh start my-vm
Simulate a failure by stopping the libvirt service on the primary node:
sudo systemctl stop libvirtd
Check if Pacemaker moves the VM to the secondary node:
sudo crm status
The output should indicate that the VM is now running on the secondary node.
Common Issues and Fixes |
|
|
Monitoring |
Use crm
to monitor the status of your cluster:
sudo crm status
You can also use the pcs
tool for additional monitoring:
sudo pcs status
By combining KVM and Pacemaker on Fedora, you can create a robust high-availability environment for your virtual machines. This setup ensures that in case of a failure on one node, your VMs will automatically fail over to another node with minimal downtime. Whether you’re running production workloads or managing critical applications, high availability is crucial to ensuring business continuity.
Did you find this article helpful? Your feedback is invaluable to us! Feel free to share this post with those who may benefit, and let us know your thoughts in the comments section below.
Learn how to install KVM on Fedora 41 step-by-stepâcovering prerequisites, CLI & GUI configuration, networking, performance tuning, and best practices for virtualized environments. Table of
In this tutorial, we will review the Arch Linux Installation process on KVM. The installation procedure for Arch Linux is different from your standard Linux
In this tutorial, we’ll guide you through the step-by-step installation of RHEL9 on KVM. The process is uncomplicated, and we’ll present it in a format