Linux Virtualization with Xen

Source: Internet
Author: User

Xen is the new virtualization kid on the block. It's gaining visibility and importance at a, only projects such as Linux and Apache has seen before. Xen have been around for a couple of Years:it is originally part of the Xenoserver platform, which aimed to build a publi C Infrastructure for Wide-area distributed computing. Ian Pratt, the principal investigator of the Xenoserver project at the University of Cambridge computer Laboratory, still leads the development team.

Xen ended up being much more than a part of the This project. Now many Linux distributions and some hardware vendors is picking it up. As with many important open source projects these days, it even have a company--xensource--backing commercial versions and Providing support for corporate customers. XenSource also employs several industry veterans. In short, Xen (source) have everything a good open source platform need to becomes an extremely important player in the Indu Stry.

At X-tend, one of our main problems is that we didn ' t has enough machines to test all new distributions and applications . Basically there was no financially realistic-to-provide our users with a quick test environment. My guess is, half of the planet has similar problems.

Ages ago, we used Usermodelinux, but the most new users found it too complex for use. Later, we bootstrapped Qemu instances from our central imaging server. That worked. If we wanted to does some tests on a isolated environment, we quickly started Qemu with the distribution we needed. The only annoyance is, we actually wanted an environment, is constantly online and, in the event of a power Outa GE (This was a test environment, not production), we didn ' t has to spend too much time getting it back. It had to is scriptable and automatable, and preferably would not require X.

With the arrival of Xen last year, all of that changed. This article describes how we tackled our problem and how we actually now has a stable and performant environment to test Everything we want. It's so stable, we are use with Xen for production environments!

What ' s Xen?

Xen is a vsan monitor for xsupports the execution of multiple guest operating systems with UNP recedented levels of performance and resource isolation. Xen is open source software, released under the terms of the GNU general public License.

Xen have become one of the most popular virtualization platforms during the last six months. Although it ' s not such a young project, it's now gaining acceptance in the corporate world as a valuable alternative to V Mware.

Adding Xen to your machine changes it from the ordinary xto a totally new platform. It ' s not a xanymore. It ' s a Xen machine. All the operating systems, want to run on your machine won ' t work anymore if they know only aboutx86; They need to know about Xen. Of course, the Xen and xarchitecture is really similar, so for the end user and the applications this run on A platform ported to Xen, there is almost no difference.

When the Xen is activated, it'll also need to boot their first virtual machine, called Domain0. Domain0 have more privileges than the other virtual machines and typically are used only for managing the other (less privil eged) virtual machines. Domain0 is also responsible for managing the hardware. Porting a platform to Xen changes almost nothing to the drivers, which means that most drivers supported in traditional Li Nux Kernels also work in Xen.

Within Domain0, the xend daemon handles the management of the virtual machines. Control it via the xm command-line utility.

From there, can-create other virtual machines, or domains.

Xen and Different Distributions

We ' ve been running Xen on different platforms ranging from an "antique" Suse 8.2 with a 2.4 series kernel, a Debian box , and Fedora Core 4 with a fresh 2.6 kernel. Unlike some other projects, the Xen currently doesn ' t care whether the use of 2.4 or 2.6, so people who is comfortable with a 2. 4 kernel can still benefit from the Xen features. However, the future releases probably won ' t has 2.4 support. People claim that installing Xen was difficult, but it's not, certainly if you compare it and other similar tools. ge Txen.org is the place to start; It contains a tarball with most of the required binaries and tools, a demo CD, and pointers to the source code. Some distributions such as Fedora include prebuilt packages. As of this writing, the official stable Xen release was 2.0.7, but most people was already working with the 3.0 betas. 3.0 might is out by the time you actually read this.

It ' s really easy to start. Here's how we deployed a Debian Vsan on a Fedora Core 4 install. We opted for a minimal FC4 install. After the installation, we updated, upgraded, and installed Xen with a couple of small commands:

yum updateyum install xenyum install kernel-xen0yum install kernel-xenU

Can it get easier? You should now carefully inspect your grub.conf file and find a part similar to:

title Xen 2.0 / XenLinux 2.6.9  kernel /boot/xen.gz dom0_mem=131072  module /boot/vmlinuz-2.6.9-xen0 root=/dev/hda1 ro console=tty0

Your version numbers may vary. If that's there, then it's time to reboot into the that new entry. Voilá, your now has your first virtual machine up and running. Yes, at first sight the regular Linux version you had just booted into isn ' t running on a regular xanymore bu T is running on a Xen.

If you already started xend at boot time, run to see xm list output similar to:

HOSTA:/etc/xen/scripts # xm listName              Id  Mem(MB)  CPU  State  Time(s)  ConsoleDomain-0           0      123    0  r----     41.2
Building a Virtual Host

Your Next step is to create another virtual machine. The easiest-on-the-either-to-download an existing chroot image of the distribution-like or to-build one you Rself. Xen can use file-backed virtual block devices (DD If=/dev/zero of=vmdisk bs=1k seek 2048k count=1), physical devices (the actual  /dev/hda9 ), LVM volumes ( phy:volumegroup/root_volume ), or an NFS root for your virtual Mach Ines. I prefer to use logical volumes on my machines, as they is really flexible to work with. with a existing disk  /dev/sda5  available, I created logical volumes to the use of my virtual machine:

pvcreate /dev/sda5vgcreate vm_volumes /dev/sda5vgchange -a y vm_volumeslvcreate -L4096 -nroot.dokeos vm_volumeslvcreate -L2048 -nvar.dokeos vm_volumeslvcreate -L256 -nswap.dokeos vm_volumeslvcreate -L1024 -nwww.dokeos vm_volumes

I usually create a directory /vhosts on my dom0 host where I mount my partitions. From there, I install the first FC4 base packages with a chroot on the actual future root device.

yum --installroot=/vhosts/root.dokeos/ -y groupinstall Base

You need to make a couple of the quick fixes to make sure the can open your initial console and so forth:

MAKEDEV -d /path/dev -x consoleMAKEDEV -d /path/dev -x nullMAKEDEV -d /path/dev -x zer

It ' s almost ready. Now, need the configuration file for this virtual machine. Most of the Xen ' s config files live in /etc/xen. You need a separate config, file for each virtual machine, want to deploy on your host. They look like:

[[email protected] xen]# cat dokeos.x-tend.bekernel = "/boot/vmlinuz-2.6.11-1.1366_FC4xenU"memory = 128name   = "dokeos.x-tend.be"nics   = 1extra  = "selinux=0  3"vif    = [‘ip = "10.0.11.13", bridge=xen-br0‘]disk   = [‘phy:vm_volumes/root.dokeos,sda1,w‘         ,‘phy:vm_volumes/var.dokeos,sda3,w‘         ,‘phy:vm_volumes/www.dokeos,sda4,w‘         ,‘phy:vm_volumes/swap.dokeos,sda2,w‘         ]root   = "/dev/sda1 ro"

The config file is rather straightforward, and the Xen packages include examples. Now start your virtual machine with the command xm create config file . ADD A to this command to see the machine -c booting. You should get a login prompt within seconds. That's how fast a physical machine should also boot, but I'll keep on dreaming for a couple of years.

If you create a symlink to the /etc/xen/auto directory, your virtual machines would start at boot time, if you ena ble thexendomains script at boot time

Linux Virtualization with Xen

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.