Introduction

Master virtualization with this comprehensive guide to setting up a VirtIO standalone and High Availability (HA) cluster on Rocky Linux 9. Whether you’re new to virtualization or an experienced IT professional, this guide simplifies the process into clear, actionable steps. We’ll cover everything from installing Rocky Linux, configuring VirtIO drivers, and creating virtual machines using the Cockpit web interface. Let’s get started!

Part 1: Setting Up VirtIO Standalone

Preparation

Verify KVM Installation: Check if KVM is installed by running:

lsmod | grep kvm

If KVM is installed, you’ll see output similar to:

kvm_intel             364544  0
kvm                   1056768  1 kvm_intel
irqbypass              16384  1 kvm

If no output appears, KVM is not installed.

Install KVM and Virtualization Tools: Install KVM and essential packages:

sudo dnf install -y qemu-kvm libvirt virt-manager virt-install

Add additional tools:

sudo dnf install -y epel-release
sudo dnf install -y bridge-utils virt-top libguestfs-tools virt-viewer

Enable KVM in BIOS: Ensure virtualization is enabled in your BIOS.

Load KVM Modules: If needed, manually load KVM modules:

sudo modprobe kvm_intel  # For Intel CPUs
sudo modprobe kvm_amd    # For AMD CPUs

Start and Enable libvirtd Service:

sudo systemctl enable --now libvirtd

Hardware Compatibility: Ensure your hardware supports virtualization. Check if your CPU supports VT-x (Intel) or AMD-V (AMD) using:

egrep -c '(vmx|svm)' /proc/cpuinfo

A result greater than 0 indicates support.

Step 1: Preparing Rocky Linux 9

  • Download Rocky Linux 9 ISO from the Rocky Linux Official Download Page.
  • Create a bootable USB using tools like Rufus (Windows) or dd (Linux).
  • Boot from the USB and select “Virtualization Host” during installation to include virtualization packages.

Step 2: System and Network Configuration

  • Log in and configure the network via the Network Manager GUI or nmcli.
  • Update the system:
sudo dnf update -y

Step 3: Install Virtualization Packages

Ensure KVM and related tools are installed:

sudo dnf install -y qemu-kvm libvirt virt-install virt-manager

Enable and start libvirtd:

sudo systemctl enable --now libvirtd

Step 4: Obtain and Configure VirtIO Drivers

  • Download WHQL-certified VirtIO drivers from the Fedora VirtIO Driver Download Page.
  • Keep these drivers ready for use during the installation of Windows-based VMs to ensure stability and compatibility.

Installing VirtIO Drivers in Windows VMs:

  1. During the Windows installation, click “Load Driver” when prompted for disk drives.
  2. Browse to the VirtIO ISO and select the appropriate driver.
  3. Install network and other drivers once the OS is set up for optimal performance.

Part 2: Configuring a High Availability Cluster

Initial Cluster Setup

Install HA tools on all cluster nodes:

sudo dnf install -y pacemaker corosync pcs

Start and enable the PCS daemon:

sudo systemctl enable --now pcsd.service

Set a password for the hacluster user:

sudo passwd hacluster

Authenticate nodes:

sudo pcs cluster auth node1 node2 -u hacluster

Creating and Configuring the Cluster

Initialize the cluster on one node:

sudo pcs cluster setup --name my_cluster node1 node2

Start and enable the cluster:

sudo pcs cluster start --all
sudo pcs cluster enable --all

Configuring Cluster Resources

Add a virtual IP resource:

sudo pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=192.168.122.100 cidr_netmask=24 op monitor interval=30s

Cluster Node Fencing: Configure fencing to prevent split-brain scenarios:

sudo pcs stonith create my_stonith fence_ipmilan ipaddr=192.168.0.100 login=admin passwd=secret pcmk_host_list=node1,node2

Common Troubleshooting Steps

  • Cluster Status Check: Run sudo pcs status to check cluster health and resource status.
  • Restart Cluster Service: If a node isn’t responding, restart services:
sudo systemctl restart pacemaker corosync
  • Log Analysis: Use journalctl -u pcsd or sudo tail -f /var/log/cluster/corosync.log to identify issues.
  • Resource Move: Move a resource manually if needed:
sudo pcs resource move VirtualIP node2

Part 3: Creating Your First VM Using Cockpit

Accessing Cockpit

Install Cockpit and the machines extension:

sudo dnf install -y cockpit cockpit-machines

Enable Cockpit:

sudo systemctl enable --now cockpit.socket

Access Cockpit at https://<your-server-IP>:9090 and log in.

Creating a New VM

  • Navigate to “Virtual Machines” and click “Create New VM”.
  • Enter VM details: Name, installation method (ISO), memory, and CPU allocation.
  • For storage, select “Add Disk” and choose a VirtIO disk.
  • Set the network model to VirtIO.
  • Attach the downloaded VirtIO drivers if creating a Windows VM for better performance.
  • Complete the installation by following on-screen prompts and installing additional VirtIO drivers in Windows if needed.

Common Issues During VM Creation

  • No Bootable Device Found: Ensure the correct ISO is selected and boot order is set.
  • Driver Issues in Windows: Ensure VirtIO drivers are loaded during setup.
  • Network Connectivity Problems: Check the network bridge configuration and confirm that the VM is using the correct VirtIO network driver.

Part 4: Verifying and Managing the Cluster

Checking Cluster Status

Run:

sudo pcs status

This shows the health and resources managed by the cluster.

Managing Cluster Resources

To move a resource:

sudo pcs resource move VirtualIP node2

Replace “node2” with your desired node.

Backup and Recovery

To create snapshots of VMs:

virsh snapshot-create-as --domain <VM_NAME> <SNAPSHOT_NAME>

Ensure backups are taken regularly to enable quick recovery from failures.

Testing High Availability

Simulate failures to ensure automatic recovery. Perform tests in a non-production environment to validate HA functionality.

Conclusion

This guide has walked you through setting up a VirtIO standalone configuration and an HA cluster on Rocky Linux 9, complete with VirtIO driver integration for enhanced performance. Keep experimenting and refining your setup to meet your specific infrastructure needs. Welcome to the world of efficient virtualization with Rocky Linux 9!

Last Update: November 16, 2024

Tagged in:

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,