Tip

Ganeti clustered virtualization on Linux

The Ganeti project is a tool for managing virtual instances across a cluster. It works with Xen or KVM as the underlying hypervisor and leverages a number of other open source projects such as DRBD to accomplish tasks

    Requires Free Membership to View

like RAID across the network. 

This tip will take a look at installing the latest stable release (version 2.2) and getting it working on a two-node cluster. We’ll go through the necessary steps including a few things we picked up from the Ganeti IRC channel (#ganeti on freenode).

Setting up your system for Ganeti
For this tip we chose to go with Debian Lenny as the base operating system because many of the published tutorials were based on this distribution. The easiest way to do the installation is to download the net install image from the main Debian site. For our purposes we downloaded the amd64 image and burned the ISO image to a CD. This method works best if you have a reasonably fast connection to the Internet.

There are a few things to keep in mind as you go about the installation process. Ganeti needs a separate partition to use for storing virtual instances. This must be formatted to use the logical volume manager (LVM) and will require additional configuration later during the installation process. Another thing to keep in mind is the importance of kernel version numbers. Xen runs on top of an existing kernel, and you need to keep the kernel versions matched up to avoid compatibility issues.

Naming becomes critical when you have a large number of nodes. For this reason Ganeti requires fully qualified domain names (FQDNs) for all cluster nodes. You’ll need to make a few changes in several files if you took the default installation choices. These include /etc/hosts and /etc/hostname. You can quickly tell if you have naming configured correctly with the following command:

 $ hostname

It should return something of the form debian1.mydomain.net instead of simply debian1. You’ll need to edit these two files to make the changes and then execute /etc/init.d/hostname.sh start to set the new names. The real IP address of your node should also be used in the /etc/hosts file as well.

Ganeti and Xen virtualization
While Ganeti works with both KVM and Xen, this tip focuses on Xen. This is where the kernel version number is critical. The easiest way to perform the necessary steps is to switch to user root and then use the apt-get command as follows:

 $ su root
 password: XXXXXXX
 # apt-get install xen-hypervisor-3.2.1-amd64 xen-linux-system-2.6.26-2-xen-amd64 xen-utils-3.2-1 xen-tools

Once this process is complete you’ll need to reboot into the new kernel. The uname command should show the following:

 $ uname –r
 2.6.26-2-xen-amd64

The final step is to add a new network device for bridging between the virtual instances and the real Ethernet port. This requires an edit to /etc/network/interfaces to add the following:

 auto xen-br0
 iface xen-br0 inet static
    address YOUR_IP_ADDRESS
    netmask YOUR_NETMASK
    network YOUR_NETWORK
    broadcast YOUR_BROADCAST_ADDRESS
    gateway YOUR_GATEWAY
    bridge_ports eth0
    bridge_stp off
    bridge_fd 0

This will create a new device named xen-br0 at the YOUR_IP_ADDRESS static address. Be sure to replace the other “YOUR” labels with the appropriate entries for your network. With the edit completed, you must start the interface with the following command:

 # ifdown eth0 ifup xen-br0

Installing Ganeti
One final step that must be accomplished prior to installing Ganeti is to configure the LVM volume group. Assuming you have a partition (ours was /dev/sda3) configured for LVM, the commands are:

 # pvcreate /dev/sda3
 # vgcreate xenvg /dev/sda3

Now we’re ready to do the actual installation of Ganeti. To get the latest version you must add a line to the /etc/apt/sources.list file to include the backports repository. The lines to add are:

 deb http://backports.debian.org/debian-backports lenny-backports main
 deb http://backports.debian.org/debian-backports lenny-backports main

With this done you must update the apt sources database with the following command:

 # apt-get update

Finally, we can install Ganeti with this line:

 # apt-get install ganeti2

We had to accomplish one final thing before Ganeti would actually start and that was to create a directory as follows:

 # cd /root
 # mkdir .ssh

At this point the cluster is ready to be initialized with:

 # gnt-cluster init cluster1.mydomain.net

This will create all the necessary processes and default configuration files to initialize the cluster. To join a second node to the cluster you accomplish all the previous steps with the exception of the gnt-cluster init command. Make sure you give the new node a unique name and IP address as well. To join the new node to the cluster you issue the command:

 # gnt-node add cluster1.mydomain.net

You can see all nodes in the cluster with the command:

 # gnt-node list

The main Ganeti site has documentation with a complete set of installation instructions. If you happen to get stuck, there’s an IRC channel on freenode (#ganeti) where you should be able to get help. My thanks go to the members there for helping us over a few “operator” errors.

ABOUT THE AUTHOR: Paul Ferrill has a BS and MS in electrical engineering and has been writing about computers for over twenty years. He's had articles published in PC Magazine, PC Computing, InfoWorld, Computer World, Network World, Network Computing, Federal Computer Week, Information Week, and multiple websites.

This was first published in January 2011

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.