1、服务器环境及Xen版本:
CentOS 5.4 64bit
Xen-3.4.3,已经自带安装包
2、自制本地yum源:
安装httpd,指向本地xen yum源
3、修改yum.repo使其指向本地yum源:
[base]
name=CentOS-$releasever - Base
baseurl=http://127.0.0.1/centos/$releasever/os/$basearch/
gpgcheck=0
enabled=1
[updates]
name=CentOS-$releasever - Updates
baseurl=http://127.0.0.1/centos/$releasever/updates/$basearch/
gpgcheck=0
enabled=1
[gitco-xen3.4.3]
name=RHEL/CentOS-$releasever - GITCO XEN3.4.3
baseurl=http://127.0.0.1/xen3.4.3
gpgcheck=0
enabled=1
4、生成最新的yum cache:
yum clean all
yum makecache
5、安装Xen:
yum install xen xen-devel xen-libs
yum install kernel-xen kernel-xen-devel(这里的kernel-xen一定要安装,可能在上一步已经安装了kernel-xen)
6、修改grub:
此时在/boot/目录下会发现多了关于 el5xen 的文件,这就是带有xen的镜像文件。
下面需要修改grub.conf文件,使用el5xen的内核文件(这里有可能安装kernel-xen时已经修改了grub.conf文件):
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/sda2
# initrd /initrd-version.img
#boot=/dev/sda
default=0 (这里一定要是带有xen内核的title)
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-238.12.1.el5xen)
root (hd0,0)
kernel /xen.gz-3.4.3
module /vmlinuz-2.6.18-238.12.1.el5xen ro root=LABEL=/
module /initrd-2.6.18-238.12.1.el5xen.img
title CentOS (2.6.18-164.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/
initrd /initrd-2.6.18-164.el5.img
7、重启服务器:
重启完服务器,确认已经使用带有xen的内核。
[[email protected] ~]# uname -a
Linux localhost.localdomain 2.6.18-238.12.1.el5xen #1 SMP Tue May 31 14:02:29 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
8、xen安装完成:
[[email protected] ~]# xm li
Name ID Mem VCPUs State Time(s)
Domain-0 0 7955 8 r----- 18.6