LAMP in Xen

Seems all the cool kids are playing with xen now. Last night I took my first real stab at it and was amazed. Following Michael’s steps I got xen up in no time and found that it just works with our qemu images from rBuilder. With a couple tweaks it is even better. Here are the steps to get LAMP running in a xen domU.

First you need a few xen specific versions of things.


conary update mkinitrd=rtao.rpath.org@rpl:devel
conary update kernel=rtao.rpath.org@rpl:devel[xen]
conary update {glibc,glibc-utils,nscd}=rtao.rpath.org@rpl:devel[xen]
conary update bridge-utils=rtao.rpath.org@rpl:devel
conary update xen=rtao.rpath.org@rpl:1

Now reboot into the new xen enabled kernel.

You should be able to run sudo xm list and see your running dom0.

Now get your LAMP image.

Next step is to create a file that defines your domU, here is an example:

kernel = "/boot/vmlinuz-2.6.16.11-1.smp.xen.x86.i686.cmov"
ramdisk = "/boot/initrd-2.6.16.11-1.smp.xen.x86.i686.cmov.img"
memory = 128
name = "lamp0"
vif = [ '' ]
disk = [ 'file:/path/to/lamp-1.0.0-x86.img,xvda,w' ]
root = "/dev/xvda1 ro"

Youl will need to change file:/path/to/lamp-1.0.0-x86.img to where your image really is. Save that file as /etc/xen/lamp0. Time to boot this sucker, xm create -c lamp0. This creates a starts your domU and gives you a console. You will notice a warning in the boot process that your glibc isn’t xen friendly, we will address that shortly. You also might see some mingetty respawning error messages, we will fix that too.

When the boot finishes, you should have a console with a login prompt. Login as root, there is no password in this image. Congratulations, you are now running a domU!

First step would be to fix a few things. We need install the xen friendly glibc.
sudo conary update glibc=rtao.rpath.org@rpl:devel

Also, we need to remove or comment out these lines from the /etc/inittab file:
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

Please note that is 2 – 6, leave 1 there.

The thing that amazed me is that networking just works. If you have a dhcp server on your network, your domU has an real IP and fully networked. To try it, start the web server (sudo service httpd start) and find your IP (ifconfig). Pop that IP in your web browser and you should get the apache default page! Cool, huh?

If you do not have a dhcp server, you will need to configure the interface in the domU.

This entry was posted in Geek. Bookmark the permalink.