Building high-availability clusters with Xen virtual machines

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

    Requires Free Membership to View

(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.

Figure 1
I recommend using a storage device such as a logical volume as the storage back end. (Click image for an enlarged view.)

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.

Figure 2
Configuring the basic parameters of a Xen virtual machine resource. (Click image for an enlarged view.)

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.

Figure 3
To create a Xen virtual machine resource, provide the path to the virtual machine configuration file. (Click image for an enlarged view.)

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.

This was first published in October 2009

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.