首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

进入开源虚拟机 XEN 的世界(2)安装使用-1

进入开源虚拟机 XEN 的世界(2)安装使用-1

XEN 的安装与使用在本例中我们安装的是 Fedora13,其中主要步骤内容都是按照 Xen 官网中的安装步骤翻译来得,也是我实际安装过程中使用的步骤。需要注意的是,在进行的分区的时候,给 /boot 目录分配至少 2GB 大小,选择类型为 ext3。然后再创建一个 LVM PV( 物理卷 ),并且在其上创建 LVM Volume 组,之后在 LVM Volume Group 上创建根目录 /root,分配大小至少 40G,选择类型为 ext4,再创建一个 swap 分区。对于 LVM volume group 安装需要注意的是必须预留足够多的空余空间来安装客户的虚拟机。下面是一个 F13 安装过程中分区的一个截屏。
图 2. F13 安装过程中分区截屏安装完成后我们需要进行一些相关的配置,当我们以 root 用户登陆的时候,我们可以通过以下命令让网络在系统启动的时候被自动 enable。
清单 1. 配置系统自动启动网络服务
1
2
# chkconfig network on
# /etc/init.d/network start




当你的网络已经启动好了,你就可以用 ssh 来远程设置网络环境,例如通过使用 ifconfig 来设置相关 ip 地址等等。网络配置完成后,我们就可以在线安装一些常用的工具。
清单 2. 安装常用工具
1
# yum install screen vim wget tcpdump ntp ntpdate man smartmontools ethtool




编辑“/boot/grub/grub.conf”和修改“timeout=10”,注释掉 hiddenmenu 这一行,修改后大概就如下所示:
清单 3. 修改后的 grub.conf 信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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_f13-lvroot
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
title Fedora (2.6.33.3-85.fc13.x86_64)
       root (hd0,0)
       kernel /vmlinuz-2.6.33.3-85.fc13.x86_64 ro
       root=/dev/mapper/vg_f13-lvroot rd_LVM_
       LV=vg_f13/lvroot rd_LVM_LV=vg_f13/lvswap rd_NO_LUKS rd_NO_MD rd_NO_DM
       LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=fi rhgb quiet
       initrd /initramfs-2.6.33.3-85.fc13.x86_64.img




修改过后,我们就可以选择相关内核进行启动了,再这之前我们先把 selinux 关掉,因为这个过于严格了。编辑“/etc/selinux/config” disable 掉这个选项。
清单 4. 修改过的 selinux 配置文件
1
2
3
4
5
6
7
8
9
10
# 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




安装 xorg-x11-xauth,这样我们就可以在 ssh 中使用 x11.
清单 5. 安装 xorg-11-xauth
1
# yum install xorg-x11-xauth




所有的设置以及配置完成后,重启系统进行 Xen4.0 的安装。先安装一些相关的开发工具及相关的 Libraries。
清单 6. 安装相关开发工具及 Libraries
1
2
# yum groupinstall "Development Libraries"
# yum groupinstall "Development Tools"




接着安装一些额外的包,主要是用于 build Xen 和运行时需要用到的。
清单 7. 安装 build Xen 用到的额外包
1
2
3
4
# 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




再安装一些 32bit 版本的 glibc-devel。
清单 8. 安装 glibc-devel
1
# yum install glibc-devel.i686




完成这些相关的包安装过后我们就可以接着进行。从 src.rpm 源码包 build 出 Xen 4.0.1 rpm 二进制安装包。你可以从 Fedora koji 或者任意的 Fedora14 FTP 镜像点 ftp://ftp.funet.fi/pub/mirrors/f ... .0.1-6.fc14.src.rpm), or from: http://pasik.reaktio.net/fedora/xen-4.0.1-6.fc14.src.rpm . 获得 xen src.rpm 的源码包。
清单 9. 下载和安装 Xen 源码包
1
2
# wget http://pasik.reaktio.net/fedora/xen-4.0.1-6.fc14.src.rpm
# rpm -i xen-4.0.1-6.fc14.src.rpm




接着重新 build 源码包获得二进制包。
清单 10. build 源码包获得二进制安装包
1
2
# cd /root/rpmbuild/SPECS
# rpmbuild -bb xen.spec




在 build 完成之后你就会看到如下信息:
清单 11. build 完成后的显示信息
1
2
3
4
5
6
7
8
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




安装新 build 出来的 rpm 包:
清单 12. 安装新 build 出来的 rpm 包
1
2
3
4
5
6
7
8
9
10
11
# cd /root/rpmbuild/RPMS/x86_64/
# rpm -Uvh *4.0.1-6*.rpm
Preparing...                ########################################### [100%]
  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          ########################################### [100%]




下载或者编译 Linux 2.6.32.x 的 Xen dom0 kernel,从 xen.git 下载内核并且 checkout 下来 2.6.32.x 整个分支:
清单 13. 下载编译 Linux2.6.32.x 的 Xen-dom0-kernel
1
2
3
# 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




接着可以用以下命令来 check 一下最新的分支更新:
清单 14. check 最新的分支更新
1
# git log | less




下载 2.6.32.x 内核的相关配置文件,也可以运行老的”oldconfig”来使配置文件与当前的内核版本兼容:
清单 15. 下载配置文件并运行配置命令
1
2
3
# 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




接下来就可以 build 内核了,将以下命令中的“-j4”中的 4 替换成你当前机器中的物理 cpu 个数,以此来加快速度。
返回列表