大概是折腾了两天,终于把Xen给成功安装上了。刚开始是用CentOS7,安装好了却启动不了有Xen的内核,然后是改成CentOS6.5,却还是出现一样的场景,最后将UFEI启动改成BOIS启动终于是成功了。也应该是走了不少弯路吧,该遇到的问题都遇到过了,能不能安装成功我觉得运气成分也比较大。
本文使用的是CentOS官方推荐的Xen4CentOS6,也可以使用Xen made Easy官方提供的解决方案,其实网上的教程基本都大同小异。
CentOS6.5系统安装以后,首先是要关闭SELinux的功能(缺省为enforcing状态):
[root@centos ~]# getenforce
Enforcing
[root@centos ~]# vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
更新系统,安装perl工具包(Xen工具需要使用Perl工具包,CentOS最小安装不支持Perl):
[root@centos ~]# yum install perl
[root@centos ~]# yum update
[root@centos ~]# reboot
安装Xen对象的软件包
[root@centos ~]# yum install centos-release-xen
[root@centos ~]# yum install xen
安装完支持 Xen的Linux内核后需要加新条目到 grub.conf,以便系统能默认启动带 Xen的Linux 内核(而不是常规 Linux 内核),这个操作可以通过grub-bootxen.sh 自动完成,弄完后打开 grub.conf 文件再次确认一下即可:
[root@centos ~]# /usr/bin/grub-bootxen.sh
[root@centos ~]# cat /boot/grub/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/mapper/vg_centos-LogVol01
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.10.32-11.el6.centos.alt.x86_64)
root (hd0,0)
kernel /xen.gz dom0_mem=1024M,max:1024M loglvl=all guest_loglvl=all
module /vmlinuz-3.10.32-11.el6.centos.alt.x86_64 ro root=/dev/mapper/vg_centos-LogVol01 rd_NO_LUKS rd_LVM_LV=vg_centos/LogVo
l00 rd_LVM_LV=vg_centos/LogVol01 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM LANG=en_U
S.UTF-8 rhgb quiet
module /initramfs-3.10.32-11.el6.centos.alt.x86_64.img
.....
重启系统后,默认应该进入 Xen 内核,可以通过 uname -r 和 xl info 确认是否安装成功:
[root@centos ~]# uname -r
3.10.32-11.el6.centos.alt.x86_64
[root@centos ~]# xl info
host : xen01.vpsee.com
release : 3.10.25-11.el6.centos.alt.x86_64
version : #1 SMP Fri Dec 27 21:44:15 UTC 2013
machine : x86_64
nr_cpus : 8
nr_nodes : 1
cores_per_socket : 4
threads_per_core : 1
cpu_mhz : 2393
hw_caps : 1febfbff:28100800:00000000:00003f40:80982201:00000000:00000001:00000000
virt_caps :
total_memory : 8191
free_memory : 7073
free_cpus : 0
xen_major : 4
xen_minor : 2
xen_extra : .3-26.el6
xen_caps : xen-3.0-x86_64 xen-3.0-x86_32p
xen_scheduler : credit
xen_pagesize : 4096
platform_params : virt_start=0xffff800000000000
xen_changeset : unavailable
xen_commandline : dom0_mem=1024M,max:1024M loglvl=all guest_loglvl=all
cc_compiler : gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
cc_compile_by : mockbuild
cc_compile_domain : centos.org
cc_compile_date : Tue Dec 10 20:32:58 UTC 2013
xend_config_format : 4
注意:重启后一定要用root权限运行xl命令,不然会出现以下错误:
xc: error: Could not obtain handle on privileged command interface (13 = Permission denied): Internal error
libxl: error: libxl.c:116:libxl_ctx_alloc: cannot open libxc handle: Permission denied
cannot init xl context
[1]. http://blog.csdn.net/jinguangliu/article/details/19993411
[2]. http://www.vpsee.com/2014/01/install-xen-on-centos-6-5/
[3]. https://wiki.centos.org/zh/HowTos/Xen/Xen4QuickStart