Needs updating and formatting
http://wiki.xensource.com/xenwiki/XenOverview
Xen can run two types of Virtual Machines:
http://en.wikipedia.org/wiki/Xen
Generic Xen is managed using the “xm” command line interface which is significantly different than the “xe” tools used in XCP or XenServer.
There are also various other management consoles or tools for managing Xen:
http://www.xen.org/products/cloudxen.html
XCP is a free open-source bare-metal type 1 hypervisor originally based on XenServer.
http://wiki.xen.org/wiki/Command_Line_Interface
XCP is managed using “xe” commandline tools.
http://www.citrix.com/xenserver
XenServer is a bare-metal type 1 hypevisor. It is free but the license has to be renewed by Citrix and every year.
XenServer is managed via a Windows application, XenCenter, or using “xm” commandline tools.
Xen requires hardware
egrep '^flags.*(vmx|svm)' /proc/cpuinfo
Dom0 (Host OS)
Use 64-Bit for best performance and in order to be able to run 64-bit guests.
Use hardware supports Intel VT or AMD SVM for fully virtualized guests (Windows).
http://www.howtoforge.com/high-performance-xen-on-ubuntu-8.04-amd64
Install the Ubuntu Hardy Heron (x86_64) Server Edition
Create and install into a 10GB partition for Dom0
apt-get update apt-get upgrade apt-get install ubuntu-xen-server apt-get install vim openssh-server
vi /etc/modules loop max_loop=64
uname -a xm list
Minimal Server Install - CentOS 5
Use separate disk partition
mkfs.ext3 /dev/sdxn
mount /dev/sdxn /mnt debootstrap --arch amd64 hardy /mnt http://archive.ubuntu.com/ubuntu mount --bind /dev /mnt/dev mount proc /mnt/proc -t proc chroot /mnt /bin/bash
Open another terminal and copy some files to the new guest partition. You may need to create some folders first.
cp /etc/resolv.conf /mnt/etc/resolv.conf cp /etc/network/interface /mnt/network/interface cp /etc/apt/source.list /mnt/etc/apt/sources.list cp /etc/apt/source.list /mnt/etc/apt/sources.list cp -R /lib/modules/2.6.24-17-xen/* /mnt/lib/modules/2.6.24-17-xen/
Back in the original (chroot'ed) terminal:
apt-get update apt-get upgrade apt-get install vim ssh
Edit the /etc/fstab
file:
/dev/hda1 / ext3 defaults 1 2
passwd exit #the chroot environment umount /mnt/dev /mnt/proc /mnt
Create the Xen configuration file adjusting the IP addressing
vi /etc/xen/domu1.cfg kernel = '/boot/vmlinuz-2.6.24-17-xen' ramdisk = '/boot/initrd.img-2.6.24-17-xen' memory = '512' # # Disk device(s). # root = '/dev/hda1 ro' disk = [ 'phy:/dev/sda2,hda1,w', ] # # Hostname # name = 'domu1' # # Networking # vif = [ 'ip=192.168.1.102,mac=00:16:3E:62:DA:BB' ] # # Behaviour # on_poweroff = 'destroy' on_reboot = 'restart' on_crash = 'restart' vcpus = '2' extra = 'xencons=tty1' xm create /etc/xen/domu1.cfg -c xm list
Centos Guest
LAMP image on Centos 5 saved in /vm/xen on appserv
Create Centos 5 VM
http://mirrors.easynews.com//linux/centos/5.0/os/i386/
ln -s /etc/xen/vm01 /etc/xen/auto
chkconfig –list |grep “3:on” |awk '{print $1}' |sort
Disable TLS mv /lib/tls /lib/tls.disabled
Start xendomains service to stop/start the Xen domains listed in /etc/xen/auto
chkconfig –add xendomains
To stop or start all Xen domains in /etc/xen/auto service xendomains stop|start|restart
Start the xend management daemon chkconfig xend on
Minimal Services http://www.redhatmagazine.com/2007/03/09/understanding-your-red-hat-enterprise-linux-daemons/
Helpful Commands
Sometimes things get confused and communications fail:
/etc/init.d/xend restart
Other useful commands:
xm help xm list xm create vmname (start VM) xm console vmname control-] (exit domU to dom0 console) xm shutdown vmname xm destroy vmname (emergency shutdown) virt-install
Backup
Backup is not so simple. Image files are pre-allocated and very large - keep them small! They also change frequently so they get backed up every backup run in a file-by-file backup.
Need disk-block backup or LVM snapshots.
This script suspends, creates a compressed copy of the disk image and resumes all running Xen domains: xen_backup.sh
In BackupPC, I use this DumpPreUsrCmd:
$sshPath -l root $host /usr/local/bin/xen_backup.sh
You can check the log like this:
tail -50 /var/log/xen/xen_backup.log
Currently, on Linus, the woodstock backup is blacked out except for 3:00am Monday morning. This allows BackupPC on appserv to complete any lengthy full backups over the weekend.
The DumpPreUsrCmd script suspends/resumes each VM in turn: ISPConfig shuts down for about 1:10, appserv for about :39 and mgmt takes about :48 minutes.
Virtual Machine Manager
http://virt-manager.et.redhat.com/
yum install kernel-xen xen virt-manager
The “Virt Install” tool (virt-install for short command name, virtinst for package name) is a command line tool which provides an easy way to provision operating systems into virtual machines.
The “Virt Clone” tool (virt-clone for short command name, virtinst for package name) is a command line tool for cloning existing inactive guests. It copies the disk images, and defines a config with new name, UUID and MAC address pointing to the copied disks.
The “Virt Image” tool (virt-image for short command name, virtinst for package name) is a command line tool for installing guest operating systems based on a pre-defined master image. The image provides metadata describing the requirements of the operating system, minimal resource allocations, and pre-installed disk.
The “Virtual Machine Viewer” application (virt-viewer for short package name) is a lightweight interface for interacting with the graphical display of virtualized guest OS. It uses GTK-VNC as its display capability, and libvirt to lookup the VNC server details associated with the guest. It is intended as a replacement for the traditional vncviewer client, since the latter does not support SSL/TLS encryption of x509 certificate authentication.
Live Migration
'
# virt-clone \
–original demo \
–name newdemo \
–file /var/lib/xen/images/newdemo.img
'
/etc/xen/scripts/vif-bridge: Could not find bridge device xenbr0
Last changed (in Tomboy): 2010-11-15 Note created (in Tomboy): 2007-07-28