Xen 是一个开放源代码虚拟机监视器,由剑桥大学开发。它打算在单个计算机上运行多达100个满特征的操作系统。操作系统必须进行显式地修改(“移植”)以在Xen上运行(但是提供对用户应用的兼容性)。这使得Xen无需特殊硬件支持,就能达到高性能的虚拟化。
本文将撰写在CentOS系统上安装和配置Xen的过程:
安装需要的软件包首先最小化安装 CentOS,然后安装编译 Xen 和 Linux xen kernel 所需要的软件包:
# yum groupinstall "Development Tools"
# yum install hmaccalc ncurses-devel zlib-devel openssl-devel python-devel bridge-utils libtool-ltdl iasl xorg-x11-drv-evdev xorg-x11-drv-fbdev xorg-x11-drv-i810-devel xorg-x11-drv-vima-devel xorg-x11-proto-devel xorg-x11-server-sdk xorg-x11-xtrans-devel
到下载并安装acpica,进入解压缩包中的compiler目录中,
# make
# make install
到 下载最新的 Xen 源代码,然后解开、编译、安装,标准的 Linux 软件源码安装动作:
# tar zxvf xen-4.0.0.tar.gz
# cd xen-4.0.0/
# make xen tools stubdom
# make install-xen install-tools install-stubdom
注意:在个操作的过程中可能会出现错误 ,如下:
遇错:`makeinfo' is missing on your system
yum -y install readline-devel gcc gcc-gfortran gcc-c++ flex pcre-devel blas-devel lapack-devel curl-devel bison gperf gnuplot texinfo-tex tetex-dvips
遇错: 错误2:提示需要安装软件包:dev86
解决办法:http://www.debath.co.uk/dev86/下载并按装
.......................................................................................
上面 make stubdom 的时候会从网上自动下载一些东西,所以如果是用代理上网的话需要在自己根目录下的 .wgetrc 里加上代理服务器,以便 wget 能通过代理正常下载:
# vim .wgetrc
http_proxy = use_proxy = on加入到启动脚本:
# /sbin/chkconfig --add xend
# /sbin/chkconfig --add xendomains
# /sbin/chkconfig xend on
# /sbin/chkconfig xendomains on
下载 Linux 内核后给内核打 xen 补丁:
# cd
# wget
# tar -xjf linux-2.6.31.8.tar.bz2
# wget http://Gentoo-xen-kernel.googlecode.com/files/
# mkdir xenpatch-2.6.31.8
# cd xenpatch-2.6.31.8
# tar -xjf ../xen-patches-2.6.31-10.tar.bz2
# cd ..
# cd linux-2.6.31.8
# for i in `ls ../xenpatch-2.6.31.8/`; do patch -p1 < ../xenpatch-2.6.31.8/"#i"; done
配置带 xen 的 Linux 内核:
# make menuconfig
Processor type and features --->
[*] Enable Xen compatible kernel
Networking support --->
Networking options --->
<*> 802.1d Ethernet Bridging
Devimce Drivers --->
XEN --->
[*] Privimleged Guest (domain 0)
Backend driver support
Block-devimce backend driver
Block-devimce tap backend driver
Block-devimce tap backend driver 2
Network-devimce backend driver
PCI-devimce backend driver
SCSI backend driver
USB backend driver
<*> Block-devimce frontend driver
<*> Network-devimce frontend driver
SCSI frontend driver
USB frontend driver
<*> Framebuffer-devimce frontend driver
<*> Keyboard-devimce frontend driver
[*] Disable serial port drivers
<*> Export Xen attributes in sysfs
Xen version compatibility (3.3.0 and later) --->
3.3.0 and later
配置好内核参数以后,保存并退出,开始编译 Linux 内核:
# make
# make modules
# make modules_install
# make install
# /sbin/depmod 2.6.31.8
更新 grub:
# vim /boot/grub/menu.lst
... title CentOS (2.6.31.8-xen) root (hd0,0) kernel /xen-4.0.0.gz module /vmlinuz-2.6.31.8 ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.31.8.img ...重启系统,确认 Xen 安装成功:
# reboot
# uname -a
Linux localhost.localdomain 2.6.31.8 #2 SMP Tue Apr 20 11:19:19 SAST 2010 x86_64 GNU/Linux
# xm list
Name ID Mem VCPUs State Time(s)
Domain-0