This three-part series explains step by step how to create a Xen-based high-availability cluster with only open source components. Part one covers how to implement an iSCSI storage area network (SAN) with SUSE Linux Enterprise Server (SLES) 11. The second installment explains how to configure a cluster with open source Pacemaker. Finally, this article covers how to create Xen-based virtual machines for the cluster.
Once you virtualize servers in your data center, a single outage on a physical server can take down multiple virtual machines (VMs). A high-availability (HA) cluster enables you to restart a VM in the cluster once its hosting node fails. So, if node one fails in your virtual environment, for example, virtual machines will migrate to node two. This way, if a server goes down, essential services don't have to shut down along with it.
Before a Xen virtual machine can be managed by a cluster and run on any node, however, a node must have access to the VM's configuration file and storage back end. Here I explain how to enable access to both.
Enabling access to a VM's configuration file
Making your VM's configuration files accessible every node is simple. First, place it on a logic unit number (LUN) in your SAN. Next, mount it on the /etc/xen/vm directory with all the hosts participating in the cluster. Then, put the configuration file on a network file share, which should be mounted on the directory, or synchronize the files manually after making changes to the configuration file (which you won't do often). Providing access to VMs' storage back end, however, requires a different approach.
Configuring the storage back end
There are two ways to configure a virtual machine's storage back end. The default method is to place it in a file. In this scenario, make the file accessible to every host in the cluster. It's also recommended to put this file on a cluster-safe file system, such as Oracle´s Oracle Cluster File System 2.
The simpler option is to set up a device as the storage back end. When creating a VM, configure the installation program to use a logical volume as the storage back end. Just be sure that the logical volume is on a LUN in the SAN and that it's available to every host in the cluster.
Configuring the Xen resource
Once the various Xen components are in place, it's time to create the cluster resource. First, start the hb_gui utility from the host server and authenticate as the user hacluster. Next, select Configuration, then Resources. From there, click Add and then choose the Primitive option. Next, provide an ID for the resource ("Xen-node" would be a good name for the test run). Then, choose the Class OCF, Provider Heartbeat and Type Xen. Once completed, click Forward.
In the next window, you can further configure the properties of your new Xen resource. On the Instance Attributes tab, specify the correct Xen virtual machine configuration file in the xmfile parameter. Then, provide the full path to the virtual machine configuration file, and click Apply. This creates the resource for your virtual machine in the cluster.
At this point, in the Management section of the hb_gui utility, the virtual machine resource will be visible but not activated. Right-click on it, and select Start. Congratulations: You now have your first virtual machine running in the cluster.
About the expert
Sander van Vugt is an independent trainer and consultant based in the Netherlands. Van Vugt is an expert in Linux high availability, virtualization and performance and has completed several projects that implement all three. He is also the writer of various Linux-related books, such as Beginning the Linux Command Line, Beginning Ubuntu Server Administration and Pro Ubuntu Server Administration.