Installing Ganeti is a relatively simple process on Gentoo. This post will go over the basics on getting it running on Gentoo. Its based primarily on a wiki page at the OSUOSL so check it out for more detailed instructions. I also recommend you read the upstream docs on Ganeti prior to installing it on your own. It will cover a lot more topics in detail and this post is intended just as a diff from that doc.

I should note that I have only installed Ganeti with KVM and have not tested it with Xen on Gentoo. I appreciate feedback if you have installed and used Xen with Ganeti on Gentoo. I’m also the current package maintainer for Ganeti and the related packages in Gentoo such as:

The first step is to install a base Gentoo system using the standard profile. You can use a hardened profile however if you intend to use ganeti-htools, it requires haskell which seems to have issues in hardened.

Configuring DNS

Ganeti requires the following names to resolve before you can set it up.

  • A master name for the cluster, this IP must be available (ganeti.example.org)
  • A name for each node or Dom0 (node1.example.org)
  • A name for each instance or virtual machine (instance1.example.org)

Kernel

DRBD is optional in Ganeti so you can skip this step if you’re not planning on using it. DRBD was recently included in the mainline kernel in 2.6.33 however Gentoo’s DRBD packages do not currently reflect that. I hope to get that changed soon but for now you have two options.

  1. Install gentoo-sources, drbd, and drbd-kernel
  2. Install gentoo-sources & enable drbd, install drbd without deps

For simplicity, I’ll describe option #2 above below. Check out the wiki page for #1.

DRBD requires you have the following option enabled. Make sure you’ve rebooted using a kernel with these options above before you continue.

Device Drivers --->
    <*> Connector - unified userspace <-> kernelspace linker

We recommend that you keyword both sys-cluster/drbd and sys-cluster/drbd-kernel so that you pull in the latest 8.3.x version.

echo "sys-cluster/drbd" >> /etc/portage/package.keywords
echo "sys-cluster/drbd-kernel" >> /etc/portage/package.keywords

Install DRBD.

emerge drbd

Ganeti uses DRBD in a unique way and requires the module to be loaded with specific settings. Add the autoload settings and load the module.

echo "drbd minor_count=255 usermode_helper=/bin/true" >> /etc/modules.autoload.d/kernel-2.6
modprobe drbd

If you forget this step, you will get an error similar to the one mentioned in this email thread.

Install Ganeti

Set the appropriate USE flags. In this case we will be using kvm with drbd.

echo "app-emulation/ganeti kvm drbd" >> /etc/portage/package.use

Install Ganeti (you might need to keyword other dependencies)

emerge ganeti

Configure Networking

There’s currently two methods for setting up networking: bridged or routed. I picked the bridged method mainly because I’m familiar with the setup and it seemed to be the simplest.

Ideally you should have a public network that will be used for communicating with the nodes and instances from the outside, and a backend private network that will be used by ganeti for DRBD, migrations, etc. Assuming your public IP (which node1.example.org should resolve to) is 10.1.0.11 and your backend IP is 192.168.1.11, you should edit /etc/conf.d/net to look something like this:

bridge_br0="eth0"
config_eth0=( "null" )

config_br0=( "10.1.0.11 netmask 255.255.254.0" )
routes_br0=( "default gw 10.1.0.1" )

# make sure eth0 is up before configuring br0
depend_br0() {
        need net.eth0
}

config_eth1=( "192.168.1.11 netmask 255.255.255.0" )

You can have a more complicated networking setup using VLAN tagging and bridging but I’ll go over that in another blog post.

Set the Hostname

Ganeti is picky about hostnames, and requires that the output of hostname be fully qualified. So make sure /etc/conf.d/hostname uses the FQDN and looks like this:

HOSTNAME="node1.example.org"

NOT like this:

HOSTNAME="node1"

Configure LVM

It is recommended that you edit this line in /etc/lvm/lvm.conf

filter = [ "r|/dev/nbd.*|", "a/.*/", "r|/dev/drbd[0-9]+|" ]

The important part is the

r|/dev/drbd[0-9]+|

entry, which will prevent LVM from scanning drbd devices.

Now, go ahead and create an LVM volume group with the disks you plan to use for instance storage. The default name that Ganeti prefers is xenvg but we recommend you choose something more useful for your infrastructure (we use ganeti).

pvcreate /dev/sda3
vgcreate ganeti /dev/sda3

Initialize the Cluster

Now we can initialize the cluster on the first node. The command below will do the following:

  • Set br0 as the primary interface for Ganeti communication
  • Set 192.168.1.11 as the DRBD ip for the node
  • Enable KVM
  • Set the default bridged interface for instances to br0
  • Set the default KVM settings to 2 vcpus & 512M RAM
  • Set the default kernel path to /boot/guest/vmlinuz-x86_64
  • Set the master DNS name is ganeti.example.org
gnt-cluster init --master-netdev=br0 \
  -g ganeti \
  -s 192.168.1.11 \
  --enabled-hypervisors=kvm \
  -N link=br0 \
  -B vcpus=2,memory=512M \
  -H kvm:kernel_path=/boot/guest/vmlinuz-x86_64
  ganeti.example.org

Now you have a ganeti cluster! Lets verify everything is setup correctly.

$ gnt-cluster verify
Sun May 16 22:43:00 2010 * Verifying global settings
Sun May 16 22:43:00 2010 * Gathering data (1 nodes)
Sun May 16 22:43:02 2010 * Verifying node status
Sun May 16 22:43:02 2010 * Verifying instance status
Sun May 16 22:43:02 2010 * Verifying orphan volumes
Sun May 16 22:43:02 2010 * Verifying remaining instances
Sun May 16 22:43:02 2010 * Verifying N+1 Memory redundancy
Sun May 16 22:43:02 2010 * Other Notes
Sun May 16 22:43:02 2010 * Hooks Results

Yay!

SSH Keys

Ganeti uses ssh to run some tasks but not for all tasks. During the initialization, it generated a new ssh key for the root user and installs it in /root/.ssh/authorized_keys. In our case, we manage that file with cfengine, so to work around it we copy the key as /root/.ssh/authorized_keys2 which ssh will automatically pick up.

Adding nother node

To add an additional node, you duplicate the setup steps above skipping initializing the cluster. Instead run the following command:

gnt-node add -s <node drbd_ip> <node hostname>

Next steps…

The next steps is actually deploying new virtual machines using Ganeti. I wrote a new instance creation script called ganeti-instance-image which uses disk images for deployment. I’m currently working on a new project website with detailed documentation and a blog post about it as well. We’re able to deploy new virtual machines (such as Ubuntu, Centos, or Gentoo) in under 30 seconds using this method!

Be Sociable, Share!
  • Twitter
  • Facebook
  • email
  • LinkedIn
  • HackerNews
  • Reddit
  • Szymon

    Great post, ganeti looks very promising, i think i’ll try it on our beowulf cluster. I’m looking forward to your website.

  • prometheanfire

    I have to say, ganeti is looking good. Be sure to post when you have your site up.

  • Thomas

    Are you running Linux only VMs or Windows as well?
    I am still on the lookout for a virtualization manager.
    Right now I am using libvirt with NFS and KVM but I am not totally satisfied so I might give ganeti a try after all.

    • lance

      I am only running Linux VMs on Ganeti. You might be able to get Windows to run on Ganeti but only with a manual installation. But any of the extra features such as import/export/automatic deployment won’t work.

      I’m not a windows admin so I don’t know of the various methods for fast deployment. Ganeti creates new VMs by creating the filesystem and either doing a direct install in a chroot or in my case dump a filesystem. If you can find a way to do this via linux host, then it should work well.

      You might also check the Ganeti mailing list and see if anyone has asked this question already, and if not you could!

  • prometheanfire

    I have a few questions
    You are using Gentoo as the host OS and if so, hardened?
    Gentoo is the guest OS?
    If Gentoo is the guest, do you build binary packages and share them? This is what I currently do with my guests even though it needs synchronized use flags.
    Does Ganeti support iSCSI as a back end?
    Because of DRBD is basically raid 1 over the network, I don’t think it is scalable to 100s of nodes (or even 10s), is this correct?

    Thanks

    • lance

      > You are using Gentoo as the host OS and if so, hardened?

      Yes for the host, no for the hardened profile. We initially used hardened but ran into an issue when we needed to add the ganeti-htools package which requires haskell. I ran into an issue where I could not get haskell to work in a hardened environment at all so I just opted to go back to non-hardened. You should be able to get that fixed but I didn’t have to time to deal with it.

      > Gentoo is the guest OS?

      Yes along with CentOS, Debian, Ubuntu, Fedora, and Slackware currently.

      > If Gentoo is the guest, do you build binary packages and share them? This is what I currently do with my guests even though it needs synchronized use flags.

      Yes we have a shared binary server but we use ‘-Ng’ for our flags so that if the useflag is different, it’ll fallback to compile it with the correct useflags.

      > Does Ganeti support iSCSI as a back end?

      Yes and no. There’s currently no Cluster LVM support in Ganeti, but its been mentioned on the mailing list several times. Ganeti supports plain LVM but it has no awareness of Cluster LVM. I imagine it will be added fairly soon. I’m looking forward to seeing that feature as well!

      > Because of DRBD is basically raid 1 over the network, I don’t think it is scalable to 100s of nodes (or even 10s), is this correct?

      This entirely depends on how you have your backend network setup and how many instances you have running per node. We currently have 4 nodes with 15 instances on each node and only see 5-10Mbps of DRBD backend traffic per node. If you had 100s of nodes you will probably want to split those up into smaller clusters so that it reduces that problem. But I could be wrong too, that’s just what I’m assuming. You might ask folks on the mailing list to see what they think.

      • prometheanfire

        Mind telling me how to enable -Ng in make.conf?

        Thanks for the quick reply

        I’m in the #gentoo-hardened #gentoo-server and #kvm if you have a sec (same nic as posted here).

      • prometheanfire

        https://bugs.gentoo.org/313635
        this patch works with x86/amd64
        here, have a quote:
        01:33 prometheanfire, if you use x86/amd64 the patch in the bug is safe (I am using it), and it should be safe to use on other platforms too. We are just having a discussion on how to best hack the shit before someone fixes the upstream buildsystem to allow people to add cflags during build.

        • prometheanfire

          odd, it left out that xake said that

        • lance

          Cool, I’ll add it to the list of things to test eventually. Thanks for mentioning the bug!

  • http://www.toltech.nl Bas Tichelaar

    I’m trying to get this to work (Live Migration with Ganeti), but my kernel resides inside my VM. Does this work for you, Lance?

  • lance

    Yes, however there’s currently a bug with kvm-clock that causes the VMs to freeze after migrating. The fix is to force the VMs to use a different clocksource other than kvm-clock. You can set that with a boot parameter in grub. I recommend something like “clocksource=tsc” to get it to work.

  • http://www.toltech.nl Bas Tichelaar

    I got it working, thanks. Are you using DRBD on LVM or DRBD on LVM on RAID? I tested with RAID-0 but got horrible performance…

  • http://www.telengy.net Gregory

    Hello,

    I’m trying to install your script “ganeti-instance-image” on CentOS 5.5 (tried also on 5.4) – I get stuck at the very moment I run “autogen.sh”. It produces this output:
    configure.ac:33: error: possibly undefined macro: AC_PROG_MKDIR_P
    If this token and others are legitimate, please use m4_pattern_allow.
    See the Autoconf documentation.

    I tried to install all version of this script you have there – the same result. I’ve also re-install all “development” programs on my system… no result.

    I’m afraid it can be due to Automake version installed by CentOS being 1.9.6 but I don’t know what to do about it….

    Please help – I have just a “stock” CentOS install with Ganeti already running there.

  • http://www.telengy.net Gregory

    I’ve found your “original” script page here:
    http://code.osuosl.org/projects/ganeti-image
    The tgz file pointed there – “http://code.osuosl.org/attachments/download/3/ganeti-instance-image-0.4.tar.gz”
    does _NOT_ have this problem. As a matter of fact – there is a ready-made “configure” script which simply works (the source code’s tar ball has “autogen.sh” script which complains the above mentioned error, when used. So, after finding your 0.4.tar.gz install – the life is again beautiful :-))
    Thanks a lot!

  • januszzz

    if that is still you, who maintains Ganeti in Portage, I really want to say thank you! (if not, won’t hurt anyway :-)

    We do always have very very fresh Ganeti and I – as well as many others – can use it very quickly and the whole system works efficiently.

    • lance

      Yes, I’m the maintainer of Ganeti in Portage.

  • simmel

    Hi there Lance,

    I’m quite interested in building a Ganeti-Xen-Cluster. I stumbled upon your blog while searching for valuable information.

    I’ve got a few questions about the usage and I’m still searching for some sort of “visual” explanation, but it looks like Madame Google isn’t of much help.

    I’d like to ask if you’d be so kind to help me a little bit with my open questions?

    Thanks for your response,
    Simmel

    • lance

      I’ll try writing a post eventually that better visualized it. In the meantime I’d recommend you check out my latest ganeti slides which include some nice pictures.

  • januszzz

    You’ve wrote:

    “pvcreate /dev/sda3
    lvcreate ganeti /dev/sda3″

    while it should be:

    “pvcreate /dev/sda3
    vgcreate ganeti /dev/sda3″

    Later use lvcreate, if ganeti doesn’t do (I’m moving from flat files to lvm so I’ll know soon).

    • lance

      Thanks for pointing that out. Fixed on the post!