Virtualization With Xen On CentOS 6.3 (x86_64) (Paravirtualization & Hardware Virtualization) - Page 2

4 Paravirtualization

4.1 Creating An Image-Based Virtual Machine

We will create our image-based virtual machines in the directory /var/lib/libvirt/images/ which was created automatically when we installed libvirt.

CentOS has a nice tool called virt-install with which we can create virtual machines for Xen. To start it, we simply run

virt-install --prompt --network bridge=br0 --virt-type=xen

(We must specify our network bridge with --network bridge=br0 so that the virtual machine uses our network bridge which we created in chapter2.)

The tools asks a few questions before it creates a virtual machine. I want to call my first virtual machine vm01, with 1024MB RAM and a disk size of 10GB. I want to store it in the file /var/lib/libvirt/images/vm01.img:

Would you like a fully virtualized guest (yes or no)? This will allow you to run unmodified operating systems.
<-- no
What is the name of your virtual machine?
<-- vm01
How much RAM should be allocated (in megabytes)?
<-- 1024
What would you like to use as the disk (file path)?
<-- /var/lib/libvirt/images/vm01.img
How large would you like the disk (/var/lib/libvirt/images/vm01.img) to be (in gigabytes)?
<-- 10
What is the install URL?
<-- http://ftp.tu-chemnitz.de/pub/linux/centos/6.3/os/x86_64

In this chapter I want to create a paravirtualized guest, not a fully (hardware) virtualized guest, that's why I answer the first question with no.

As install URL, you should specify a mirror close to you where the installer can download all files needed for the installation of CentOS 6.3 in our virtual machine. You can find a list of CentOS mirrors here: http://www.centos.org/modules/tinycontent/index.php?id=13

After we have answered all questions, virt-install starts the normal CentOS 6.3 installer (in text mode) in our vm01 virtual machine. After a few moments the installer gives you the choice to use VNC or to continue with the text mode installer. Using text mode is no problem if you are familiar with the CentOS installer, but if you like a little more comfort, select Start VNC here:

On the next screen you can provide a password for the VNC connection (recommended). If you don't want to use a password, hit No password:

Afterwards, the installer tells you how you can connect to the installer via VNC (192.168.0.15:1 in this case):

Now open a VNC client (like TightVNC) and type in the connection details (192.168.0.15:1 in this case) and click on Connect:

If you have specified a password for the VNC connection, you must now provide it:

Afterwards you can use the CentOS installer in your VNC client:

After the installation, we stay at the vm01 console. To leave it, type CTRL+] if you are at the console, or CTRL+5 if you're using PuTTY. You will then be back at the dom0 console.

Run

virsh console vm01

to log in on that virtual machine again (type CTRL+] if you are at the console, or CTRL+5 if you're using PuTTY to go back to dom0), or use an SSH client to connect to it.

To get a list of running virtual machines, type

virsh list

The output should look like this:

[root@server1 ~]# virsh list
 Id Name                 State
----------------------------------
  0 Domain-0             running
  2 vm01                 idle

[root@server1 ~]#

To shut down vm01, do this:

virsh shutdown vm01

To start vm01 again, run

virsh start vm01

Here are the most important Xen commands:

virsh start <name> - Start a virtual machine.
virsh shutdown <name> - Stop a virtual machine.
virsh destroy <name> - Stop a virtual machine immediately without shutting it down. It's as if you switch off the power button.
virsh list - List all running systems.
virsh console <name> - Log in on a virtual machine.
virsh help - List of all commands.

 

4.2 Creating An LVM-Based Virtual Machine (Paravirtualization)

This chapter explains how you can set up LVM-based virtual machines instead of virtual machines that use disk images. Virtual machines that use disk images are very slow and heavy on disk IO.

In this example I'm using a CentOS 6.3 host with the LVM volume group /dev/VolGroup00 that has about 465GB of space. /dev/VolGroup00 contains two logical volumes, /dev/VolGroup00/LogVol00 and /dev/VolGroup00/LogVol01 that consume about 104GB of space - the rest is not allocated and can be used to create logical volumes for our virtual machines:

vgdisplay

[root@server1 ~]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               465.26 GiB
  PE Size               4.00 MiB
  Total PE              119106
  Alloc PE / Size       26250 / 102.54 GiB
  Free  PE / Size       92856 / 362.72 GiB
  VG UUID               LCdZgy-jVrp-S92Q-RQeI-H87G-jiko-4fmaHF

[root@server1 ~]#

lvdisplay

[root@server1 ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                n5remv-KYEE-O0Ry-g2r6-OrUe-rjyV-x65rHu
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                4.88 GiB
  Current LE             1250
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                CnvnGP-sDL8-OtBU-OzTT-VjZQ-ZIUo-yzISkX
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                97.66 GiB
  Current LE             25000
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1

[root@server1 ~]#

I want to create the virtual machine vm02 now which uses the logical volume /dev/VolGroup00/vm02. I want the virtual machine to have a disk space of 10GB, so I create the logical volume /dev/VolGroup00/vm02 as follows:

lvcreate -L10G -n vm02 VolGroup00

Afterwards we can run

virt-install --prompt --network bridge=br0 --virt-type=xen

again:

Would you like a fully virtualized guest (yes or no)? This will allow you to run unmodified operating systems.
<-- no
What is the name of your virtual machine?
<-- vm02
How much RAM should be allocated (in megabytes)?
<-- 1024
What would you like to use as the disk (file path)?
<-- /dev/VolGroup00/vm02
What is the install URL?
<-- http://ftp.tu-chemnitz.de/pub/linux/centos/6.3/os/x86_64

As the disk file path, we specify our new volume group /dev/VolGroup00/vm02. Please note that virt-install doesn't ask for the disk space anymore because the disk space is determined by the size of the logical volume (10GB).

Share this page:

10 Comment(s)

Add comment

Comments

From: Anonymous at: 2012-12-01 06:06:56

I found some error:

 make[3]: *** [libvirt_driver_libxl_la-libxl_conf.lo] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory `/root/rpmbuild/BUILD/libvirt-0.9.10/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/root/rpmbuild/BUILD/libvirt-0.9.10/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/rpmbuild/BUILD/libvirt-0.9.10'
make: *** [all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.ezXtRF (%build)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.ezXtRF (%build)

How can I fix that?

From: Antenor Siles Cano at: 2012-12-04 21:44:47

Estimados  me salen estos errores al querer reconpilar una vez aplicada el patch
 
make[3]: *** [libvirt_driver_libxl_la-libxl_conf.lo] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory `/root/rpmbuild/BUILD/libvirt-0.9.10/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/root/rpmbuild/BUILD/libvirt-0.9.10/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/rpmbuild/BUILD/libvirt-0.9.10'
make: *** [all] Error 2
error: Estado de salida erróneo de /var/tmp/rpm-tmp.X6DDrC (%build)
 
Errores de construcción RPM:
    Estado de salida erróneo de /var/tmp/rpm-tmp.X6DDrC (%build)
 
 
no se a que se debe este problema de espero sus comentarios gracias..!!!

From: Anonymous at: 2012-12-07 15:28:02

http://au1.mirror.crc.id.au/repo/kernel-xen-release-6-3.noarch.rpm -- its 404 url nowadays, looks like http://au1.mirror.crc.id.au/repo/kernel-xen-release-6-4.noarch.rpm is working

From: Keys2IT at: 2013-01-12 08:23:16

Hello,

getting same problem as you !
Did you manage to find a solution ?

Kind Regards,

Laurent

 

From: Ted at: 2013-01-17 05:29:55

I found the same rpmbuild error.

According to the last part of the next forum, we should use xen4.1.

  http://www.howtoforge.com/forums/archive/index.php/t-58994.html

 

When you install xen with yum, please use the next command line:

 yum install xen-4.1.3-2.el6.x86_64 xen-devel-4.1.3-2.el6.x86_64 xen-hypervisor-4.1.3-2.el6.x86_64 xen-libs-4.1.3-2.el6.x86_64 xen-licenses-4.1.3-2.el6.x86_64 lxen-runtime-4.1.3-2.el6.x86_64

From: miguel at: 2013-01-26 02:44:46

I need help!!!!!

ccc1: warning: unrecognized command line option "-Wno-suggest-attribute=const"

ccc1: warning: unrecognized command line option "-Wno-suggest-attribute=pure"

 make[3]: *** [libvirt_driver_libxl_la-libxl_conf.lo] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory `/root/rpmbuild/BUILD/libvirt-0.9.10/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/root/rpmbuild/BUILD/libvirt-0.9.10/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/rpmbuild/BUILD/libvirt-0.9.10'
make: *** [all] Error 2

 

I do not want to use windows, please!!!!

 

From: at: 2013-01-29 09:57:38

I found the solution.

see:
http://www.howtoforge.com/forums/showthread.php?t=58994&page=3

[3 Installing Xen]
# yum install kernel-xen xen
replace to this:
# yum install xen-4.1.3-2.el6.x86_64 xen-devel-4.1.3-2.el6.x86_64 xen-libs-4.1.3-2.el6.x86_64


# yum install python-devel xen-devel libxml2-devel xhtml1-dtds readline-devel ncurses-devel libtasn1-devel gnutls-devel augeas libudev-devel libpciaccess-devel yajl-devel sanlock-devel libpcap-devel libnl-devel avahi-devel libselinux-devel cyrus-sasl-devel parted-devel device-mapper-devel numactl-devel libcap-ng-devel netcf-devel libcurl-devel audit-libs-devel systemtap-sdt-devel libblkid-devel scrub
replace to this: (exclude xen-devel)
# yum install python-devel libxml2-devel xhtml1-dtds readline-devel ncurses-devel libtasn1-devel gnutls-devel augeas libudev-devel libpciaccess-devel yajl-devel sanlock-devel libpcap-devel libnl-devel avahi-devel libselinux-devel cyrus-sasl-devel parted-devel device-mapper-devel numactl-devel libcap-ng-devel netcf-devel libcurl-devel audit-libs-devel systemtap-sdt-devel libblkid-devel scrub

From: Matt at: 2013-02-15 16:13:22

Hello,

I was following the outline in this how-to (plus some hints from the comments / peanut gallery, thanks!) and had at least a (successful) build that didn't give me errors except for at bootup when the scsi_wait_scan module was not found.

I've searched the web, and from what I understand it appears as if the scsi controllers with the LVM aren't being loaded in time during bootup and that the kernel doesn't recognize the drive and it's not mounted (or some such thing, not an expert here by any means).

I think I need to add a line somewhere in the kernel build to put in that module, but am unsure how to do it.  Ideas / thoughts / comments?

From: Ted at: 2013-05-31 05:21:55

When you install Xen4.2 on CentOS6.4, you could take another way.

Replace "[3 Installing Xen]" (of this page) to the following commands.


# egrep '(vmx|svm)' --color=always /proc/cpuinfo

# yum install http://au1.mirror.crc.id.au/repo/kernel-xen-release-6-5.noarch.rpm

# yum install kernel-xen xen

# vi /boot/grub/menu.lst

# shutdown -r now

# xm info

# yum install virt-install virt-viewer libvirt python-virtinst virt-manager qemu-kvm

# /etc/init.d/libvirtd start

# echo "/usr/sbin/libvirtd -d" >>/etc/rc.d/rc.local

# xm list
# virsh list

==

I referred to the nice instructions (http://f.dataguru.cn/thread-127204-1-1.html) written by ???.

 

Caution!

After you install Xen4.2, you may encounter a lot of errors. No warranty. You should take a full backup of your server.

From: Anonymous at: 2014-04-02 04:46:32

Thank You for the guide!On the xenproject website it states that the VM manager has to have a windows client installed to control the virtual machines. Clearly, this is not the case!


 I have several questions:


1.Are there any features in the enterprise XEN version with paid support that are not availible with the management tools in linux?


2. What are the advantages of installing XEN on top of a *NIX distrubution? Why wouldnt you just install the premade ISO?


3. Is this type of XEN configuration in this guide, suitable for enterprise deployment provided one is using enterprise grade hardware?


4. Out of all the virtual machine technology availible which do you prefer for enterprise type scnerios?