二、需求分析及参考网页
首先,企业想架设XEN在服务器,且不影响其它服务的性能的前提下,所以在配置虚拟机时domain0应该设置一定的MEMORY;二编译新的内核以支持XEN的半虚拟化的支持;三创建或克隆SLAVEWRE的XEN的镜像,并能够进行像LINUX文本命令的执行;
http://www.tek-life.org/2010/05/20/centos5-4%E5%AE%89%E8%A3%85xen/
http://blog.csdn.net/handw/archive/2010/04/22/5515164.aspx
三、安装配置及错误分析
内核的升级与补丁安装
安装需要的软件包
首先最小化安装 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-via-devel xorg-x11-proto-devel \
xorg-x11-server-sdk xorg-x11-xtrans-devel
安装完以上软件包后,剩下的操作就和在 Debian 上编译和安装 Xen 差不多了。
安装 Xen hypervisor 和 tools
到 http://www.xen.org/products/xen_source.html 下载最新的 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
上面 make stubdom 的时候会从网上自动下载一些东西
# /sbin/chkconfig --add xend
# /sbin/chkconfig --add xendomains
# /sbin/chkconfig xend on
# /sbin/chkconfig xendomains on
安装 Xen 内核
下载 Linux 内核后给内核打 xen 补丁:
$ cd
$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.8.tar.bz2
$ tar -xjf linux-2.6.31.8.tar.bz2
$ wget http://gentoo-xen-kernel.googlecode.com/files/
xen-patches-2.6.31-10.tar.bz2
$ 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
配置好内核参数以后,保存并退出,开始编译 Linux 内核:
$ make
$ make modules
# make modules_install
# make install
# /sbin/depmod 2.6.31.8
更新 grub:
# vi /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 0 3713 4 r----- 36.0
安装错误分析如下
make[8]: *** [iasl] Error 1
make[8]: Leaving directory `/source/xen-4.0.0/tools/firmware/hvmloader/acpi’
make[7]: *** [subdir-all-acpi] Error 2
make[7]: Leaving directory `/source/xen-4.0.0/tools/firmware/hvmloader’
make[6]: *** [subdirs-all] Error 2
make[6]: Leaving directory `/source/xen-4.0.0/tools/firmware/hvmloader’
make[5]: *** [subdir-all-hvmloader] Error 2
make[5]: Leaving directory `/source/xen-4.0.0/tools/firmware’
make[4]: *** [subdirs-all] Error 2
make[4]: Leaving directory `/source/xen-4.0.0/tools/firmware’
make[3]: *** [all] Error 2
make[3]: Leaving directory `/source/xen-4.0.0/tools/firmware’
make[2]: *** [subdir-install-firmware] Error 2
make[2]: Leaving directory `/source/xen-4.0.0/tools’
make[1]: *** [subdirs-install] Error 2
make[1]: Leaving directory `/source/xen-4.0.0/tools’
make: *** [install-tools] Error 2
我们注意到,前面其实已经将iasl复制到usr/local/bin下了,在G.cn上搜索了一下,复制后需要改变其权限:
cd compiler ——>make——>cp iasl /usr/local/bin
chown root:root /usr/local/bin/iasl
XEN 安装完成重启不存在XEN的TITLE
因为对grub 2.0的不兼容
只能安装grub0.7
然后grub-install –recheck /dev/sda
RROR: /bin/lvm exited abnormally (pid 326)
mount: error 6 mounting ext3
mount: error 2 mounting none
switchroot: mount failed: 22
umount: /initrd/dev failed: 2
Kernel panic - not syncing: Attempted to kill init!
硬件的问题
install error: No module ehci-hcd found for kernel 2.6.18.8-xen0 (I added the module "EHCI HCD" in buildin Xen0-Kernel)
I looked at the configuration file for my current kernel and found that it had the line:
CONFIG_USB_EHCI_HCD=m
mkinitrd -v -f --with=sd_mod --with=scsi_mod
CONFIG_SCSI_BUSLOGIC=M
CONFIG_USB_HCD_UHCI=M
CONFIG_USB_EHCI_HCD=M
CONFIG_USB_OHCI_HCD=M
CONFIG_ATA_PIIX=M
CONFIG_SYSFS_DEPRECATED=y
CONFIG_SYSFS_DEPRECATED_V2=y
No module dm-mem-cache found for kernel 2.6.18-92.1.13.el5, aborting.
--without-dmraid
make
> sh> make modules
> sh> make modules_install
mount: could not find filesystem '/dev/root'
mkinitrd --with=xennet --preload=xenblk initrd.img $(uname -r)
kernel引导结束后,init切换跟分区的时候使用了设备文件/dev/root, 而这个设备文件没有被包含在新生成的initrd文件内,也没有存放在磁盘上.导致切换跟分区失败。
make ARCH=arm menuconfig
ernel Features --->
[*] Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run with this kernel (EXPERIMENTA)
把这个选上就可以了
xend is not starting
The PVOPS changed how the /proc/xen is exported to user-space. Now it is considered an XenFS filesystem that has to be mounted to be usable. Make sure you have this in /etc/fstab:
xenfs /proc/xen xenfs defaults 0 0
xm list Unable to connect to xend
/var/log/xen/xend.log
[2007-10-11 16:08:05 6461] INFO (SrvDaemon:226) Xend stopped due to
signal 15.
[2007-10-11 16:10:42 6702] INFO (SrvDaemon:331) Xend Daemon started
[2007-10-11 16:10:42 6702] INFO (SrvDaemon:335) Xend changeset:
unavailable.
[2007-10-11 16:10:42 6702] INFO (SrvDaemon:342) Xend version: Unknown.
[2007-10-11 16:10:42 6702] ERROR (SrvDaemon:353) Exception starting
xend (no element found: line 1, column 0)
Traceback (most recent call last):
File "usr/lib/python2.4/site-packages/xen/xend/server/SrvDaemon.py",
line 345, in run
servers = SrvServer.create()
File "usr/lib/python2.4/site-packages/xen/xend/server/SrvServer.py",
line 254, in create
root.putChild('xend', SrvRoot())
File "usr/lib/python2.4/site-packages/xen/xend/server/SrvRoot.py",
line 40, in __init__
self.get(name)
File "usr/lib/python2.4/site-packages/xen/web/SrvDir.py", line 82,
in get
val = val.getobj()
File "usr/lib/python2.4/site-packages/xen/web/SrvDir.py", line 52,
in getobj
self.obj = klassobj()
File "usr/lib/python2.4/site-packages/xen/xend/server/SrvNode.py",
line 30, in __init__
self.xn = XendNode.instance()
File "usr/lib/python2.4/site-packages/xen/xend/XendNode.py", line
658, in instance
inst = XendNode()
File "usr/lib/python2.4/site-packages/xen/xend/XendNode.py", line
60, in __init__
saved_host = self.state_store.load_state('host')
File "usr/lib/python2.4/site-packages/xen/xend/XendStateStore.py",
line 104, in load_state
dom = minidom.parse(xml_path)
File "/usr/lib/python2.4/xml/dom/minidom.py", line 1915, in parse
return expatbuilder.parse(file)
File "/usr/lib/python2.4/xml/dom/expatbuilder.py", line 924, in
parse
result = builder.parseFile(fp)
File "/usr/lib/python2.4/xml/dom/expatbuilder.py", line 211, in
parseFile
parser.Parse("", True)
ExpatError: no element found: line 1, column 0
安装libvir
./autogen.sh --prefix=$HOME/usr
make
make install
安装完成后执行 hg debuginstall 时出现了错误:
hg --version
abort: couldn't find mercurial libraries in [/usr/local/bin /usr/lib/python2.6 /usr/lib/python2.6/plat-linux2 /usr/lib/python2.6/lib-tk /usr/lib/python2.6/lib-old /usr/lib/python2.6/lib-dynload /usr/lib/python2.6/dist-packages /usr/lib/python2.6/dist-packages/PIL /usr/lib/python2.6/dist-packages/gst-0.10 /var/lib/python-support/python2.6 /usr/lib/python2.6/dist-packages/gtk-2.0 /var/lib/python-support/python2.6/gtk-2.0 /usr/local/lib/python2.6/dist-packages]
(check your install and PYTHONPATH)
解决方法:
export PYTHONPATH=/usr/local/lib/python2.6/site-packages
或者:
把上面的加到这两个文件中的一个: .bashrc、/etc/profile。
四.注意问题汇总
1,版本问题是linux的最头疼的问题
2,务必使用最新版本(包括:Fedora, Xen, 及各种软件)
3,坚决使用root权限安装
4,深刻理解linux的标准文件系统目录结构
5,高版本的内核环境中不能编译低版本的内核,即使编译成功,也不能启动
6,Fedora Core 6 切忌不要选择virtualization,否则就被安装为FC6-XEN
7,划分分区时,一定要预先估算可能占用的容量,尤其是编译时可能产生大量中间结果
8,安装FC时务必关闭防火墙,包括iptables和SELinux
xen 的配置
Pre-requisites
配置
打开 Xen 的配置文件,注释掉 (network-script network-bridge) 一行,然后加上下面一行:
# vi /etc/xen/xend-config.sxp #(network-script network-bridge) (network-script network-multi-bridge)
然后创建一个 network-multi-bridge 脚本,用来2次执行 network-bridge 脚本:
# vi etc/xen/scripts/network-multi-bridge #!/bin/sh dir=$(dirname "$0") "$dir/network-bridge" "$@" vifnum=0 bridge=xenbr0 netdev=eth0 "$dir/network-bridge" "$@" vifnum=1 bridge=xenbr1 netdev=eth1
重启 Xen 服务使配置生效:
# /etc/init.d/xend restart
"Unable to open a connection to the Xen hypervisor/daemon. Verify that
- a xen host kernel was booted
- the xen service has been started
When you install Xen. You will need to configure xend using the file /etc/xen/xend-config.sxp
In this file search for the following line:
#(xend-unix-server no)
uncomment it and change it to: (xend-unix-server yes)
If you want to connect to xend through http then you should uncomment and change the (xend-http-server no) to 'yes'. (This has security concerns and its not safe)
http://imcsx.com/archives/104.html
· 如果你装好的 Xen 不能正常启动,提示:
Panic on CPU 0:
IO-APIC : timer doesn't work!
或者卡在 “qc timeout”、“failed to IDENTIFY” 类似这种消息:
scsi0 : sata_sil
sata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
sata1.00: qc timeout (cmd 0xec)
sata1.00: failed to IDENTIFY (I/O error, err_mask=0x4)
时,那么可以参考一下我的 grub.conf:
kernel /boot/xen.gz noapic
module /boot/kernel-2.6.18-xen0 root=/dev/md2 console=tty1 pci=noacpi
· 在建立好一个 domU 的配置文件后,需要按照把 stage3 安装包解压到配置中指定的 root 分区中,否则会出现类似如下的错误:
VFS: Mounted root (ext2 filesystem) readonly.
Freeing unused kernel memory: 136k freed
Warning: unable to open an initial console.
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
extra = "TERM=xterm xencons=tty console=tty1"
否则你会发现 domU 启动到一定阶段后会停滞不动的假死现象:
kjournald starting. Commit interval 5 seconds
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem) readonly.
Freeing unused kernel memory: 136k freed
(以下不再输出)
slaveware 的配置文件如下
kernel = “/boot/vmlinuz-2.6.18.8-xen”
kernek =128
name = “slackware”
vif = [‘ip=192.168.122.3’]
netmask = “255.255.255.0”
hostname = “slackname”
disk = [‘file:/root/xen/slackware.11-0.img.sda,w’,’file:/rootxen/slackware.swap,sda2,w’]
root = “/dev/sda1 rw”
extra =” TERM=xterm xencons=tty console=tty1”
对/boot/grub/grub.conf的配置文件的如下
Title Xen3.4.0 (2.6.18.8)
Root (hd0,2)
kernel /boot/xen-3.4.0.gz dom0_mem=512M loglvl=all guest_loglvl=all
module /boot/vmlinuz-2.6.18.8-xen ro root=/de/sda3 console=ttyS0 console=tty0 pci=noacpi
module /boot/initrd=2.6.18.8-xen.img
升级python-lib .因为我安装的 virtul-manager是0.8.4