Steps to install Xen on CentOS:
1. Execute the following command to install Xen and Xen kernel
yum install kernel-xen xen
2. Once the installation completes, you can find the new kernel “Xen kernel (vmlinuz-2.6.18-8.1.4.el5xen)” in grub.conf file.
title CentOS (2.6.18-8.1.4.el5xen)root (hd0,0)kernel /xen.gz-2.6.18-8.1.4.el5module /vmlinuz-2.6.18-8.1.4.el5xen ro root=/dev/VolGroup00/LogVol00module /initrd-2.6.18-8.1.4.el5xen.img |
3. Change the default value as 0 in the file ‘/etc/grub.conf’
default=0
4. Create a new directory to make a virtual machine “/vm” and reboot the server
5. After the system has booted, the system has the new Xen kernel
# uname -r2.6.18-8.1.4.el5xen |
6. To check if Xen has started, execute the command – “xm list”. It should list Domain-0 (dom0):
# xm listName ID Mem(MiB) VCPUs State Time(s)Domain-0 0 350 1 r—– 94.4 |
7. A tool called “virt-install” with which we can create virtual machines for Xen
virt-install
8. The tools asks a few questions before it creates a virtual machine as follows:
What is the name of your virtual machine? <– vm01How much RAM should be allocated (in megabytes)? <– 256What would you like to use as the disk (path)? <– /vm/vm01.imgHow large would you like the disk (/vm/vm01.img) to be (in gigabytes)? <– 4Would you like to enable graphics support? (yes or no) <– no What is the install location? <– http://wftp.tu-chemnitz.de/pub/linux/centos/5.0/os/i386 |
9. virt-install has created the vm01 configuration file /etc/xen/vm01 for us (in dom0). It should look like this:
cat /etc/xen/vm01# Automatically generated xen config filename = “vm01?memory = “256?disk = [ ‘tap:aio:/vm/vm01.img,xvda,w’, ] vif = [ ‘mac=00:16:3e:13:e4:81, bridge=xenbr0?, ] uuid = “5aafecf1-dd66-401d-69cc-151c1cb8ac9e” bootloader=”/usr/bin/pygrub” vcpus=1 on_reboot = ‘restart’ |
10. To log in on that virtual machine, type: xm console vm01
That’s it
Some important Xen commands:
1. xm create -c /path/to/config – Start a virtual machine
xm create /etc/xen/vm01
2. xm shutdown – Stop a virtual machine
xm shutdown vm01
3. xm destroy – Stop a virtual machine immediately without shutting it down
xm destroy vm01
4. xm list – List all running systems
5. xm console – Log in on a virtual machine
xm console vm01
7. xm help – List of all commands
No comments:
Post a Comment