Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1048913
  • 博文数量: 254
  • 博客积分: 10185
  • 博客等级: 上将
  • 技术积分: 2722
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-25 15:04
文章存档

2011年(8)

2009年(1)

2008年(31)

2007年(214)

分类: 虚拟化

2011-07-31 21:47:53

直入主题,本文写给希望在CentOS系统中安装Xen虚拟化环境的朋友。请使用前仔细阅读本文,如果您尚不熟悉Linux终端操作,请移步。

Step.1 安装需要的软件包:

首先最小化安装 CentOS,首先使用yum升级系统

# yum update

然后安装编译 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-via-devel xorg-x11-proto-devel \ 
xorg-x11-server-sdk xorg-x11-xtrans-devel
 
到下载并安装acpica,进入解压缩包中的compiler目录中,
# make
# make install
 
Step.2 安装 Xen hypervisor:
到 下载最新的 Xen 源代码,然后解开、编译、安装,标准的 Linux 软件源码安装动作:
# tar zxvf xen-4.1.1.tar.gz
# cd xen-4.1.1/
# make world
(此过程耗时约10-15分钟)
# make install
 
Step.3 将Xen加入到启动脚本:
# /sbin/chkconfig --add xend
# /sbin/chkconfig --add xendomains
# /sbin/chkconfig --add xencommons
# /sbin/chkconfig xend on
# /sbin/chkconfig xendomains on
# /sbin/chkconfig xencommons on
 
Step.4 下载、配置并编译 Xen 内核:

下载 Linux 内核后给内核打 xen 补丁:

$ cd
$ wget
$ tar -xjf linux-2.6.31.8.tar.bz2
$ wget  
$ 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
Device Drivers --->
  XEN --->
    [*] Privileged Guest (domain 0)
     <*> Backend driver support
       <*> Block-device backend driver
       <*> Block-device tap backend driver
       <*> Block-device tap backend driver 2
       <*> Network-device backend driver
       <*> PCI-device backend driver
       <*> SCSI backend driver
       <*> USB backend driver
    <*> Block-device frontend driver
    <*> Network-device frontend driver
       <*> SCSI frontend driver
       <*> USB frontend driver
    <*> Framebuffer-device frontend driver
    <*> Keyboard-device frontend driver
    [*] Disable serial port drivers
    <*> Export Xen attributes in sysfs
        Xen version compatibility (3.3.0 and later) --->
           3.3.0 and later
注意:如果使用32位系统,则务必将PAE功能开启,将内存支持选择为64GB,否则会重启后内核将会报错。
Processor type and features --->
   High Memory Support (4GB) --->
      64GB

配置好内核参数以后,保存并退出,开始编译 Linux 内核:
# make
(此过程耗时约30-45分钟)
# make modules
# make modules_install
# make install
# /sbin/depmod 2.6.31.8

Step.5 更新 grub 引导信息:

# vi /boot/grub/menu.lst
title CentOS (2.6.31.8-xen)
    root (hd0,0)
    kernel /xen-4.1.1.gz
    module /vmlinuz-2.6.31.8 ro root=/dev/VolGroup00/LogVol00
    module /initrd-2.6.31.8.img
 
Step.6 重启系统,确认 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 0 3713 4 r----- 36.0
 
 
特别注意:
1、如果您是在VMware中安装的虚拟Linux系统,您需要在#make menuconfig配置内核时,将SCSI相关的选项编译进内核(即改为“*”),并且将".config"配置文件中的“#CONFIG_SYSFS_DEPRECATED_V2 is not set”项一行修改为“CONFIG_SYSFS_DEPRECATED_V2=y”,重新编译内核,否则会出现下列错误信息:
Mounting root filesystem.
mount: could not find filesystem ‘/dev/root’
Setting up other filesystems.
Setting up new root fs
setuproot: moving /dev failed: No such file or directory
no fstab.sys, mounting internal defaults
setuproot: error mounting /proc: No such file or directory
Switching to new root and running init.
unmounting old /dev
unmounting old /proc
unmounting old /sys
switchroot: mount failed: No such file or directory
Kernel panic – not syncing: Attempted to kill init!
2、过程中若提示缺包,请使用#yum install xxx,使用yum在线下载安装。
3、使用virt-manager提示无法连接8000端口的问题,请做出如下改动:
#vi /etc/xen/xend-config.sxp
   修改其中的#(xend-unix-server no) -> (xend-unix-server yes)
#service xend restart
阅读(1231) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~