在红貌6上安装和配置XEN
http://7cm.org/wiki/CentOs/%E5%AE%89%E8%A3%85XEN%E9%85%8D%E7%BD%AE%E7%AC%94%E8%AE%B0CentOs/安装XEN配置笔记
CentOs/管理XEN虚拟机
目录
[*]
[*]7cm 开源软件应用维基
[*]CentOs/安装XEN配置笔记
[*]硬件参数
[*]网络配置
[*]配置域名解析
[*]修改主机名
[*]修改hosts文件
[*]启动网卡0
[*]关闭 SElinux
[*]安装必备软件
[*]更新 yum
[*]安装 screen
[*]安装 vim
[*]安装 wget tcpdump ntp ntpdate man smartmontools links lynx ethtool xorg-x11-xauth
[*]安装 make gcc
[*]调整启动菜单
[*]Installing required packages to compile Xen rpms
[*]一个32位的glibc-devel也是必须的
[*]Rebuilding and installing Xen src.rpm
[*]回到上级目录 rpmbuild/SPECS
[*]安装新编译的 RPM
[*]Installing upstream Xen dom0 capable kernel
[*]git remote show origin
[*]私自更改了路径。原来的路径xen/stable-2.6.32.x不存在了。
[*]Configure the kernel
[*]install the kernel
[*]现在是时候编辑启动菜单配置文件 "grub.conf" 然后添加一个Xen+dom0 的入口:
[*]禁用 KSM services, 当前这个服务不能和 Xen 工作:
[*]重启,重启后验证 XEN
[*]Updating the dom0 kernel
[*]Using libvirt and virt-manager with Xen
[*]Install libvirt and virt-manager:
[*]之后,我们重新编译 libvirt :
[*]安装 xen-enabled rpms (需要 --force 参数,因为有些版本的 libvirt
已经安装过了):
[*]确认 "libvirtd" 在启动时会自动启动:
[*]现在重启系统,并启动 Xen 镜像!
[*]验证 libvirt with Xen
[*]让我想到了<盗梦空间>
[*]第二层梦境
[*]参考 :
安装是安装默认选项安装的,分区也没有自己定制,反正就当时测试了。 而且选的是minimal 最小化安装。
硬件参数
CentOs/安装XEN配置笔记/硬件信息
网络配置
装完之后,参考
CentOs/网络配置 配置网卡 eth0
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
HWADDR="00:15:17:02:49:E8"
NM_CONTROLLED="no"
ONBOOT="no"
BOOTPROTO="static"
IPADDR="192.168.0.19"
NETMASK="255.255.255.0"
NETWORK="192.168.0.0"
TYPE="Ethernet"
配置域名解析
vi /etc/resolv.conf
nameserver 192.168.0.1
nameserver 202.96.134.133
修改主机名
# hostname intel5000v
修改hosts文件
vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 intel5000v
启动网卡0
#ifup eth0
网络通了,但是重启之后,仍然没有自动激活网卡0, 奇怪?
问题在 ONBOOT="no" 这句,修改成 ONBOOT="yes" 问题解决。
这次可以了。
# service network restart
正在关闭接口 eth0: [确定]
关闭环回接口: [确定]
弹出环回接口: [确定]
弹出界面 eth0:
[确定]
关闭 SElinux
vi /etc/selinux/config
SELINUX=disabled
安装必备软件
更新 yum
yum update
CentOs/安装配置笔记/yum-update
安装 screen
首先安装这个软件是为了,后面有些操作需要消耗很多时间,用screen后,终端断开,任务不会终止
# yum install screen
Loaded plugins: fastestmirror
base | 3.7 kB 00:00
base/primary_db | 4.5 MB 00:09
extras | 3.5 kB 00:00
extras/primary_db | 6.3 kB 00:00
updates | 3.5 kB 00:00
updates/primary_db | 3.0 MB 00:05
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package screen.x86_64 0:4.0.3-16.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
screen x86_64 4.0.3-16.el6 base 494 k
Transaction Summary
================================================================================
Install 1 Package(s)
Total download size: 494 k
Installed size: 795 k
Is this ok : y
Downloading Packages:
screen-4.0.3-16.el6.x86_64.rpm | 494 kB 00:01
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
Package: centos-release-6-2.el6.centos.7.x86_64 (@anaconda-CentOS-201112091719.x86_64/6.2)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok : y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : screen-4.0.3-16.el6.x86_64 1/1
Installed:
screen.x86_64 0:4.0.3-16.el6
Complete!
安装 vim
yum install vim
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.ta139.com
* extras: mirrors.ta139.com
* updates: mirrors.ta139.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.2.411-1.6.el6 will be installed
--> Processing Dependency: vim-common = 2:7.2.411-1.6.el6 for package: 2:vim-enhanced-7.2.411-1.6.el6.x86_64
--> Processing Dependency: perl(:MODULE_COMPAT_5.10.1) for package: 2:vim-enhanced-7.2.411-1.6.el6.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 2:vim-enhanced-7.2.411-1.6.el6.x86_64
--> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.2.411-1.6.el6.x86_64
--> Running transaction check
---> Package gpm-libs.x86_64 0:1.20.6-12.el6 will be installed
---> Package perl.x86_64 4:5.10.1-119.el6_1.1 will be installed
--> Processing Dependency: perl(Pod::Simple) for package: 4:perl-5.10.1-119.el6_1.1.x86_64
--> Processing Dependency: perl(version) for package: 4:perl-5.10.1-119.el6_1.1.x86_64
--> Processing Dependency: perl(Module::Pluggable) for package: 4:perl-5.10.1-119.el6_1.1.x86_64
---> Package perl-libs.x86_64 4:5.10.1-119.el6_1.1 will be installed
---> Package vim-common.x86_64 2:7.2.411-1.6.el6 will be installed
--> Running transaction check
---> Package perl-Module-Pluggable.x86_64 1:3.90-119.el6_1.1 will be installed
---> Package perl-Pod-Simple.x86_64 1:3.13-119.el6_1.1 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.13-119.el6_1.1.x86_64
---> Package perl-version.x86_64 3:0.77-119.el6_1.1 will be installed
--> Running transaction check
---> Package perl-Pod-Escapes.x86_64 1:1.04-119.el6_1.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository
Size
================================================================================
Installing:
vim-enhanced x86_64 2:7.2.411-1.6.el6 base 896 k
Installing for dependencies:
gpm-libs x86_64 1.20.6-12.el6 base 28 k
perl x86_64 4:5.10.1-119.el6_1.1 base 10 M
perl-Module-Pluggable x86_64 1:3.90-119.el6_1.1 base 37 k
perl-Pod-Escapes x86_64 1:1.04-119.el6_1.1 base 30 k
perl-Pod-Simple x86_64 1:3.13-119.el6_1.1 base 209 k
perl-libs x86_64 4:5.10.1-119.el6_1.1 base 575 k
perl-version x86_64 3:0.77-119.el6_1.1 base 49 k
vim-common x86_64 2:7.2.411-1.6.el6 base 6.0 M
Transaction Summary
================================================================================
Install 9 Package(s)
Total download size: 18 M
Installed size: 54 M
Is this ok : y
Downloading Packages:
(1/9): gpm-libs-1.20.6-12.el6.x86_64.rpm |28 kB 00:00
(2/9): perl-5.10.1-119.el6_1.1.x86_64.rpm |10 MB 00:20
(3/9): perl-Module-Pluggable-3.90-119.el6_1.1.x86_64.rpm |37 kB 00:00
(4/9): perl-Pod-Escapes-1.04-119.el6_1.1.x86_64.rpm |30 kB 00:00
(5/9): perl-Pod-Simple-3.13-119.el6_1.1.x86_64.rpm | 209 kB 00:00
(6/9): perl-libs-5.10.1-119.el6_1.1.x86_64.rpm | 575 kB 00:01
(7/9): perl-version-0.77-119.el6_1.1.x86_64.rpm |49 kB 00:00
(8/9): vim-common-7.2.411-1.6.el6.x86_64.rpm | 6.0 MB 00:45
(9/9): vim-enhanced-7.2.411-1.6.el6.x86_64.rpm | 896 kB 00:01
--------------------------------------------------------------------------------
Total 217 kB/s |18 MB 01:24
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 1:perl-Pod-Escapes-1.04-119.el6_1.1.x86_64 1/9
Installing : 1:perl-Module-Pluggable-3.90-119.el6_1.1.x86_64 2/9
Installing : 4:perl-libs-5.10.1-119.el6_1.1.x86_64 3/9
Installing : 1:perl-Pod-Simple-3.13-119.el6_1.1.x86_64 4/9
Installing : 3:perl-version-0.77-119.el6_1.1.x86_64 5/9
Installing : 4:perl-5.10.1-119.el6_1.1.x86_64 6/9
Installing : gpm-libs-1.20.6-12.el6.x86_64 7/9
Installing : 2:vim-common-7.2.411-1.6.el6.x86_64 8/9
Installing : 2:vim-enhanced-7.2.411-1.6.el6.x86_64 9/9
Installed:
vim-enhanced.x86_64 2:7.2.411-1.6.el6
Dependency Installed:
gpm-libs.x86_64 0:1.20.6-12.el6
perl.x86_64 4:5.10.1-119.el6_1.1
perl-Module-Pluggable.x86_64 1:3.90-119.el6_1.1
perl-Pod-Escapes.x86_64 1:1.04-119.el6_1.1
perl-Pod-Simple.x86_64 1:3.13-119.el6_1.1
perl-libs.x86_64 4:5.10.1-119.el6_1.1
perl-version.x86_64 3:0.77-119.el6_1.1
vim-common.x86_64 2:7.2.411-1.6.el6
Complete!
安装 wget tcpdump ntp ntpdate man smartmontools links lynx ethtool xorg-x11-xauth
首先进入screen 终端。然后安装上面那些软件。
screen
yum install wget tcpdump ntp ntpdate man smartmontools links lynx ethtool xorg-x11-xauth
CentOs/安装配置笔记/安装细节2
安装 make gcc
yum install make gcc
调整启动菜单
[*]通过调整 grub.conf 增加 grub timeout 时间, 注释 "hiddenmenu" 选项:
vi /boot/grub/grub.conf
#timeout=5
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
Installing required packages to compile Xen rpms
用下面一条命令安装编译 Xen src.rpm 需要的包。
# yum groupinstall "Development tools" "Additional Development" "Debugging Tools" "System administration tools" "Compatibility libraries" "Console internet tools" "Desktop Platform Development"
CentOs/安装XEN配置笔记/安装细节3
还要安装一些附加的包,这些包在编译 Xen 是需要用到的。:
#yum install transfig wget texi2html libaio-devel dev86 glibc-devel e2fsprogs-devel gitk mkinitrd iasl xz-devel bzip2-devel pciutils-libs pciutils-devel SDL-devel libX11-devel gtk2-devel bridge-utils PyXML qemu-common qemu-img mercurial texinfo libuuid-devel
一个32位的glibc-devel也是必须的
yum install glibc-devel.i686
Rebuilding and installing Xen src.rpm
# mkdir /root/src && cd /root/src
# wget http://pasik.reaktio.net/fedora/xen-4.0.1-6.fc14.src.rpm
# rpm -i xen-4.0.1-6.fc14.src.rpm
回到上级目录 rpmbuild/SPECS
# cd /root/rpmbuild/SPECS
# rpmbuild -bb xen.spec
过一会,可以看到 :
Wrote: /root/rpmbuild/RPMS/x86_64/xen-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-libs-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-runtime-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-hypervisor-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-doc-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-devel-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-licenses-4.0.1-6.fc13.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/xen-debuginfo-4.0.1-6.fc13.x86_64.rpm
安装新编译的 RPM
(Note: This assumes you have already satisfied the dependencies for installing Xen)
Try installing the rpms:
# cd /root/rpmbuild/RPMS/x86_64/
# rpm -Uvh xen*4.0.1-6*.rpm
error: Failed dependencies:
/usr/bin/qemu-nbd is needed by xen-runtime-4.0.1-6.el6.x86_64
出现什么问题了? It seems RHEL6 does not have "qemu-common" rpm available, which includes "qemu-nbd" binary. So we need to grab qemu src.rpm from Fedora and rebuild it for RHEL6 to get the required "qemu-common" rpm.
查看RHEL6中 "qemu" 版本 :
# rpm -qa | grep qemu
qemu-img-0.12.1.2-2.209.el6_2.4.x86_64
现在打补丁。
# cd /root/src
# wget http://archives.fedoraproject.org/pub/archive/fedora/linux/updates/13/SRPMS/qemu-0.13.0-1.fc13.src.rpm
# rpm -i qemu-0.13.0-1.fc13.src.rpm
# cd /root/rpmbuild/SPECS
# rpmbuild -bb qemu.spec
安装
cd /root/rpmbuild/RPMS
# rpm -Uvh qemu-common-0.13.0-1.el6.x86_64.rpm
Preparing... ###########################################
1:qemu-common ###########################################
现在可以安装 Xen rpms:
# rpm -Uvh qemu-common-0.13.0-1.el6.x86_64.rpm
Preparing... ###########################################
1:qemu-common ###########################################
# rpm -Uvh xen*4.0.1-6*.rpm
Preparing... ###########################################
1:xen-licenses ########################################### [ 13%]
2:xen-libs ########################################### [ 25%]
3:xen-hypervisor ########################################### [ 38%]
4:xen-runtime ########################################### [ 50%]
5:xen ########################################### [ 63%]
6:xen-devel ########################################### [ 75%]
7:xen-doc ########################################### [ 88%]
8:xen-debuginfo ###########################################
Now you're done installing Xen hypervisor, tools and libraries.
Installing upstream Xen dom0 capable kernel
现在要装 upstream *Xen* kernel , 这基于 kernel.org Linux 2.6.32.x kernel. 这个 kernel 和 Redhat RHEL6 kernel是不同的. Many drivers are newer versions in Redhat's kernel, and Redhat's kernel might have more features than the kernel.org kernel. Due to the
driver version differences you might experience problems on some hardware, for example on servers using LSI/DELL RAID adapters. 可能要手动解决这些问题.
Clone the kernel git repository from kernel.org and check out the "xen/stable-2.6.32.x" long-term maintained branch.
# mkdir /root/kernel && cd /root/kernel
# git clone git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git linux-2.6-xen
# cd linux-2.6-xen
# git checkout -b xen/stable-2.6.32.x origin/xen/stable-2.6.32.x
# git checkout -b xen/stable-2.6.32.x origin/xen/stable-2.6.32.x 这一句报错!
git checkout -b xen/stable-2.6.32.x origin/xen/stable-2.6.32.x
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'origin/xen/stable-2.6.32.x' which can not be resolved as commit?
git remote show origin
# git remote show origin
* remote origin
Fetch URL: git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git
PushURL: git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git
HEAD branch: master
Remote branches:
hid-battery tracked
hid-battery-scope tracked
master tracked
power-supply-scope tracked
upstream/jump-label-noearly tracked
upstream/linux-next tracked
upstream/microcode tracked
upstream/pvticketlock-slowflag tracked
upstream/ticketlock-cleanup tracked
upstream/xen tracked
upstream/xen-settime tracked
xen/mmu-perf-tweak tracked
xen/next-2.6.32 tracked
xen/next-3.1 tracked
xen/next-3.2 tracked
xen/no-pv tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
私自更改了路径。原来的路径xen/stable-2.6.32.x不存在了。
git fetch
# git checkout -b xen/stable-2.6.32.x origin/xen/stable-2.6.32.x
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'origin/xen/stable-2.6.32.x' which can not be resolved as commit?
# git checkout -b xen/stable-2.6.32.x origin/xen/next-2.6.32
Checking out files: 100% (30367/30367), done.
Branch xen/stable-2.6.32.x set up to track remote branch xen/next-2.6.32 from origin.
Switched to a new branch 'xen/stable-2.6.32.x'
#
Configure the kernel
You can run make menuconfig, and go through the config file to manually activate the relevant Xen options. (Hint: Press the '/' key to bring up a search option, and search for 'xen'.
Alternatively, download a reference config-file for the 2.6.32.x kernel. Also run "oldconfig" to adapt the configuration to current kernel version (if it's different):
# wget -O .config http://pasik.reaktio.net/xen/pv_ops-dom0-debug/config-2.6.32.25-pvops-dom0-xen-stable-x86_64
# make oldconfig
# make clean
# make -j4 bzImage && make -j4 modules && make modules_install
....
漫长的30分钟之后
INSTALL /lib/firmware/keyspan_pda/xircom_pgs.fw
INSTALL /lib/firmware/vicam/firmware.fw
INSTALL /lib/firmware/cpia2/stv0672_vp4.bin
INSTALL /lib/firmware/yam/1200.bin
INSTALL /lib/firmware/yam/9600.bin
DEPMOD2.6.32.57
Note the example config-file above is DEBUG-enabled possibly causing big performance hits, so don't use it for performance testing!
install the kernel
接下来我们安装这个kernel 并且准备好启动镜像 initrd (initramfs) . 在本例中 Kernel 版本是"2.6.32.57":
[ linux-2.6-xen]# depmod -a 2.6.32.57
[ linux-2.6-xen]# cp -a arch/x86/boot/bzImage /boot/vmlinuz-2.6.32.57
[ linux-2.6-xen]# cp -a System.map /boot/System.map-2.6.32.57
[ linux-2.6-xen]# cp -a .config /boot/config-2.6.32.57
[ linux-2.6-xen]# cd /boot
[ boot]# dracut initramfs-2.6.32.57.img 2.6.32.57
注意!如果你使用的系统LSI和/或戴尔RAID适配器(使用megaraid_sas驱动程序),你需要手动更新驱动程序版本! Linux2.6.32.25 提供的驱动程序版本太旧,它不会“工作(磁盘将不会在系统启动时启用)。有关更新版本的驱动程序的信息:http://lists.xensource.com/archives/html/xen-devel/2010-11/msg00250.html
现在是时候编辑启动菜单配置文件 "grub.conf" 然后添加一个Xen+dom0 的入口:
-rw-r--r--. 1 root root14M5月8 01:52 initramfs-2.6.32-220.13.1.el6.x86_64.img
-rw-r--r--. 1 root root14M5月7 23:26 initramfs-2.6.32-220.el6.x86_64.img
-rw-r--r--1 root root88M5月9 18:02 initramfs-2.6.32.57.img
可以看到刚刚编译的哪个 initramfs-2.6.32.57.img 体积庞大,有88M
# 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_intel5000v-lv_root
# initrd /initrd-version.img
#boot=/dev/ddf1_4c5349202020202080862682000000004711471100001450
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
title CentOS (2.6.32-220.13.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-220.13.1.el6.x86_64 ro root=/dev/mapper/vg_intel5000v-lv_root rd_DM_UUID=ddf1_4c5349202020202080862682000000004711471100001450 rd_NO_LUKS rd_LVM_LV=vg_intel5000v/lv_root rd_NO_MD quiet rhgb crashkernel=auto LANG=zh_CN.UTF-8KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg_intel5000v/lv_swap
initrd /initramfs-2.6.32-220.13.1.el6.x86_64.img
title CentOS (2.6.32-220.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/vg_intel5000v-lv_root rd_DM_UUID=ddf1_4c5349202020202080862682000000004711471100001450 rd_NO_LUKS rd_LVM_LV=vg_intel5000v/lv_root rd_NO_MD quiet rhgb crashkernel=auto LANG=zh_CN.UTF-8KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg_intel5000v/lv_swap
initrd /initramfs-2.6.32-220.el6.x86_64.img
title Xen 4.0 with Linux 2.6.32.57 dom0
root (hd0,0)
kernel /xen.gz dom0_mem=1024M loglvl=all guest_loglvl=all
module /vmlinuz-2.6.32.57 ro root=/dev/mapper/vg_intel5000v-lv_root rd_DM_UUID=ddf1_4c5349202020202080862682000000004711471100001450rd_LVM_LV=vg_intel5000v/lv_root nomodeset
module /initramfs-2.6.32.57.img
禁用 KSM services, 当前这个服务不能和 Xen 工作:
# chkconfig ksm off
# chkconfig ksmtuned off
重启,重启后验证 XEN
#reboot
重启后,登录系统执行 :
# xm list
Name ID Mem VCPUs State Time(s)
Domain-0 01024 4 r----- 65.0
# xm info
host : intel5000v
release : 2.6.32.57
version : #1 SMP Wed May 9 17:26:03 CST 2012
machine : x86_64
nr_cpus : 4
nr_nodes : 1
cores_per_socket : 2
threads_per_core : 1
cpu_mhz : 2660
hw_caps : bfebfbff:20000800:00000000:00000180:0000e4bd:00000000:00000001:00000000
virt_caps : hvm
total_memory : 4090
free_memory : 3014
node_to_cpu : node0:0-3
node_to_memory : node0:3014
node_to_dma32_mem : node0:2487
max_node_id : 0
xen_major : 4
xen_minor : 0
xen_extra : .1
xen_caps : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_scheduler : credit
xen_pagesize : 4096
platform_params : virt_start=0xffff800000000000
xen_changeset : unavailable
xen_commandline : dom0_mem=1024M loglvl=all guest_loglvl=all
cc_compiler : gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC)
cc_compile_by : lidong
cc_compile_domain :
cc_compile_date : Tue May8 23:43:23 CST 2012
xend_config_format : 4
从上面输出,我们可以看出,当前运行的 Xen 虚拟机版本是 version 4.0.1 (xen_major, xen_minor, xen_extra) with Linux 2.6.32.57 dom0 kernel.
Updating the dom0 kernel
# mkdir /root/kernel/linux-2.6-xen
# make clean
# git pull
# git log | less
执行 git log |less 结果:
commit a938a246d34912423c560f475ccf1ce0c71d9d00
Merge: 8326829 1897bf2
Author: Jeremy Fitzhardinge <jeremy@goop.org>
Date: Mon Mar 19 10:52:00 2012 -0700
Merge commit 'v2.6.32.57' into xen/next-2.6.32
* commit 'v2.6.32.57': (22 commits)
Linux 2.6.32.57
net: sock_queue_err_skb() dont mess with sk_forward_alloc
net: fix sk_forward_alloc corruptions
mmc: cb710 core: Add missing spin_lock_init for irq_lock of struct cb710_chip
USB: usbserial: add new PID number (0xa951) to the ftdi driver
usb: Skip PCI USB quirk handling for Netlogic XLP
usb: gadget: zero: fix bug in loopback autoresume handling
Staging: android: binder: Fix crashes when sharing a binder file between processes
Staging: android: binder: Don't call dump_stack in binder_vma_open
Staging: asus_oled: fix image processing
atmel_lcdfb: fix usage of CONTRAST_CTR in suspend/resume
eCryptfs: Infinite loop due to overflow in ecryptfs_write()
drm/i915: Fix TV Out refresh rate.
udf: Mark LVID buffer as uptodate before marking it dirty
rpc client can not deal with ENOSOCK, so translate it into ENOCONN
NFSv4: Fix open recovery
NFSv4: Handle NFS4ERR_GRACE when recovering an expired lease.
NFSv4: Ensure the state manager handles NFS4ERR_NO_GRACE correctly
NFSv4: The state manager shouldn't exit on errors that were handled
NFSv4: Fix up the callers of nfs4_state_end_reclaim_reboot
...
commit 8326829847694d598382b3c5717f220e30b03137
Merge: 1aaf53e adb67a7
Using libvirt and virt-manager with Xen
Install libvirt and virt-manager:
# yum install libvirt virt-manager xorg-x11-xauth
默认的 RHEL6 下面的 libvirt 并不兼容 Xen .你可以验证这一点,通过在台式机或者笔记本上使用 带X11的 ssh 链接 dom0, 尝试运行 "virt-manager":
# virt-manager &
3050
# Traceback (most recent call last):
File "/usr/share/virt-manager/virt-manager.py", line 383, in <module>
main()
File "/usr/share/virt-manager/virt-manager.py", line 286, in main
raise gtk_error
RuntimeError: could not open display
这个错误可以通过重新编译支持XEN的 libvirt rpms 来解决。
注意! 在重新编译 libvirt src.rpm 之前,你需要重启系统,并进入一个非XEN的环境,就是标准的CENTOS环境!
这是因为 RHEL6 libvirt Xen-specific 测试在 Xen dom0 环境会失败。
Verify libvirt version in RHEL6:
# rpm -qa |grep libvirt
libvirt-client-0.9.4-23.el6_2.8.x86_64
libvirt-python-0.9.4-23.el6_2.8.x86_64
libvirt-0.9.4-23.el6_2.8.x86_64
Let's download the src.rpm from Redhat ftp server, patch the spec file to enable Xen support, and try rebuilding it.
# cd /root/src
# wget ftp://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS/libvirt-0.8.1-27.el6.src.rpm
# rpm -i libvirt-0.8.1-27.el6.src.rpm
# wget http://pasik.reaktio.net/xen/patches/libvirt-spec-rhel6-enable-xen.patch
# cd /root/rpmbuild/SPECS
# cp -a libvirt.spec libvirt.spec.orig
# patch -p0 < ~/src/libvirt-spec-rhel6-enable-xen.patch
patching file libvirt.spec
# rpmbuild -bb libvirt.spec
error: Failed build dependencies:
libnl-devel >= 1.1 is needed by libvirt-0.8.1-27.el6.x86_64
xhtml1-dtds is needed by libvirt-0.8.1-27.el6.x86_64
libudev-devel >= 145 is needed by libvirt-0.8.1-27.el6.x86_64
libpciaccess-devel >= 0.10.9 is needed by libvirt-0.8.1-27.el6.x86_64
yajl-devel is needed by libvirt-0.8.1-27.el6.x86_64
libpcap-devel is needed by libvirt-0.8.1-27.el6.x86_64
avahi-devel is needed by libvirt-0.8.1-27.el6.x86_64
parted-devel is needed by libvirt-0.8.1-27.el6.x86_64
device-mapper-devel is needed by libvirt-0.8.1-27.el6.x86_64
numactl-devel is needed by libvirt-0.8.1-27.el6.x86_64
netcf-devel >= 0.1.4 is needed by libvirt-0.8.1-27.el6.x86_64
Ok, 我们需要安装缺少的包:
# yum install libnl-devel xhtml1-dtds libudev-devel libpciaccess-devel yajl-devel libpcap-devel avahi-devel parted-devel device-mapper-devel numactl-devel netcf-devel
之后,我们重新编译 libvirt :
# rpmbuild -bb libvirt.spec
过一会儿,看到:
Wrote: /root/rpmbuild/RPMS/x86_64/libvirt-0.8.1-27.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/libvirt-client-0.8.1-27.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/libvirt-devel-0.8.1-27.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/libvirt-python-0.8.1-27.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/libvirt-debuginfo-0.8.1-27.el6.x86_64.rpm
安装 xen-enabled rpms (需要 --force 参数,因为有些版本的 libvirt 已经安装过了):
# rpm -Uvh --force libvirt-0.8.1-27.el6.x86_64.rpm libvirt-client-0.8.1-27.el6.x86_64.rpm libvirt-python-0.8.1-27.el6.x86_64.rpm
Preparing... ###########################################
1:libvirt-client ########################################### [ 33%]
2:libvirt ########################################### [ 67%]
warning: %post(libvirt-0.8.1-27.el6.x86_64) scriptlet failed, exit status 1
3:libvirt-python ###########################################
#
确认 "libvirtd" 在启动时会自动启动:
# chkconfig --list libvirtd
libvirtd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
# chkconfig --list libvirtd
libvirtd 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭
现在重启系统,并启动 Xen 镜像!
验证 libvirt with Xen
# virsh list
Id 名称 状态
----------------------------------
0 Domain-0 running
# xm list
Name ID Mem VCPUs State Time(s)
Domain-0 01024 4 r----- 69.5
So it seems to work. Now you're also able to use graphical "virt-manager" to manage Xen on RHEL6.
让我想到了<盗梦空间>
ssh -X lidong@192.168.0.19
连接上去后,输入
virt-manager
我的FreeBsd无法使用 ssh -X 直接连接到虚拟机上,但是通过我的FreeBsd中的虚拟CentOS系统,然后用 SSH -X 就连接到XEN了。
http://7cm.org/wiki/CentOs/%E5%AE%89%E8%A3%85XEN%E9%85%8D%E7%BD%AE%E7%AC%94%E8%AE%B0?action=AttachFile&do=get&target=Screenshot.png
第二层梦境
通过本机的虚拟机VirtualBox创建的CentOS6 进入intel5000V 这台 XEN Server ,然后创建虚拟机并安装。 这是第二层梦境。
http://7cm.org/wiki/CentOs/%E5%AE%89%E8%A3%85XEN%E9%85%8D%E7%BD%AE%E7%AC%94%E8%AE%B0?action=AttachFile&do=get&target=Screenshot-4.png
参考 :
[*]
http://wiki.xen.org/wiki/RHEL6_Xen4_Tutorial
[*]
http://wiki.xen.org/wiki/Compiling_Xen
[*]
http://wiki.xen.org/wiki/Compiling_Kernel_2.6.32
[*]
这是用Cent5.3安装XEN,比较简单,但是对于Cent6.2参考意义不大
[*]
http://www.howtoforge.com/virtualization-with-xen-on-centos-6.2-x86_64-paravirtualization-and-hardware-virtualization
页:
[1]