Xen is a free open source software virtual machine monitor for Intel / PowerPC architectures. It is software that runs on a host operating system and allows several guest operating systems to be run on top of the host on the same computer hardware at the same time (just like VMWare software). Luckily Installing and managing XEN is quite easy under CentOS 5 Linux.
Xen lets you create guest operating systems (*nix operating systems like Linux and FreeBSD), so called "virtual machines" or domUs, under a host operating system (dom0). Using Xen you can separate your applications into different virtual machines that are totally independent from each other (e.g. a virtual machine for a mail server, a virtual machine for a high-traffic web site, another virtual machine that serves your customers' web sites, a virtual machine for DNS, etc.), but still use the same hardware. This saves money, and what is even more important, it's more secure. If the virtual machine of your DNS server gets hacked, it has no effect on your other virtual machines. Plus, you can move virtual machines from one Xen server to the next one.
I will use CentOS 5.0 (i386) for both the host OS (dom0) and the guest OS (domU).
yum install xen virt-manager kernel-xen
chkconfig xend on
reboot
Before Reboot
Change the file /boot/grub/menu.lst then you should probably use
to default =0
After Login
type command
uname -r
2.6.18-8.1.4.el5xen
Xen commands
xm list
CentOS comes with a nice tool called virt-install with which we can create virtual machines for Xen. To start it, we simply run
virt-install
What is the name of your virtual machine? <-- vm01
How much RAM should be allocated (in megabytes)? <-- 256
What would you like to use as the disk (path)? <-- /vm/vm01.img
How large would you like the disk (/vm/vm01.img) to be (in gigabytes)? <-- 4
Would 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
virt-install has created the vm01 configuration file /etc/xen/vm01 for us (in dom0).
It should look like this: # Automatically generated xen
config file name = "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' on_crash = 'restart'
to login into
vm01 xm console vm01
To shut down vm01,
do this: xm shutdown vm01
To start vm01 again,
run xm create /etc/xen/vm01
If you want vm01 to start automatically at the next boot of the system,
then do
this: ln -s /etc/xen/vm01 /etc/xen/auto
Here are the most important Xen commands:
xm create -c /path/to/config - Start a virtual machine. xm shutdown - Stop a virtual machine.
xm destroy - Stop a virtual machine immediately without shutting it down. It's as if you switch off the power button.
xm list - List all running systems.
xm console - Log in on a virtual machine.
xm destroy
xm list - List all running systems.
xm console
No comments:
Post a Comment