热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Xen虚拟机的安装方法

虚拟化技术是云计算实现弹性计算的核心技术。在构建云计算平台中,虚拟机的安装是基

     虚拟化技术是云计算实现弹性计算的核心技术。在构建云计算平台中,虚拟机的安装是基础。常用的虚拟机工具很多,如VMware、XEN、KVM、Virtual PC等,这些工具使得用户可以在单台物理PC上(称为宿主机)虚拟出多个虚拟机VM(Virtual machine),由于在每个VM上可以安装与宿主机不同的操作系统。因而可以实现在一台物理PC上模拟出多台安装有不同操作系统的“PC”。在云计算中,用户可以向云平台申请租用虚拟机,虚拟机的配置,如CPU的核数、主频,内存,存储容量等可以根据需要自己设定,并可动态修改。现有虚拟机工具多支持这些功能,然而很多工具如VMware、XEN-Server等提供的免费测试工具多只提供GUI接口,用户只能通过图形界面实现虚拟机的创建和配置,无法实现动态的配置,以至于构建的云平台退化为不具有弹性的“虚拟机平台”。

     Xen 是由剑桥大学开发的一款开放源代码虚拟机工具软件,支持虚拟机的各种配置和动态创建,最重要的是提供了丰富的用户管理接口。

     下面为安装过程。

1.1 Linux system:

Fedora 12 x86_64

测试PC:HP4321S联想笔记本电脑

SELinux is disabled. Please refer here for detail: Disabled SELinux on Fedora.

Disable SELINUX using your favorite editor to open the SELINUX configuration file. For example:

$:su      切换到root用户

vi /etc/selinux/config

Edit the configuration file so that SELINUX has the value of "disabled". It should look like the following:

SELINUX=disabled

ext3 is recommended for the file system of disk partition for /boot.

Update the system:

# yum update

The Xen and libvirt packages in Fedora should not be installed to avoid conflict.

# yum erase xen* libvirt
【版本
title Fedora (2.6.32.26-175.fc12.x86_64) 经过update后的版本
title Fedora (2.6.31.5-127.fc12.x86_64)   安装光盘版本
重启系统,从title Fedora (2.6.32.26-175.fc12.x86_64)登录,然后继续下面的任务】
1.2 Build and install Xen hypervisor and tools 1.2.1 Download Xen3.4.3 $ wget http://bits.xensource.com/oss-xen/release/3.4.3/xen-3.4.3.tar.gz
$ tar xf xen-3.4.3.tar.gz
1.2.2 Build Xen and tools

You may need to install packages depended by this. You can try this for solving the dependencies:

# yum install make gcc -y;
yum groupinstall "Development Libraries" -y;
yum groupinstall "Development Tools" -y;
yum install transfig texi2html
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 -y

The we can make Xen and Xen tools: (xen-3.4.3目录下)

$ make xen
$ make tools
1.2.3 Install Xen and tools (xen-3.4.3目录下)
$ make install-xen
$ make install-tools
1.3 Build and install xenified Linux kernel 1.3.1 Download Linux kernel2.6.32.13
$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.13.tar.bz2
$ tar xf linux-2.6.32.13.tar.bz2
1.3.2 Download2.6.32Xen patches v2
$ wget http://gentoo-xen-kernel.googlecode.com/files/xen-patches-2.6.32-2.tar.bz2
$ mkdir xen-patches-2.6.32-2
$ tar xf xen-patches-2.6.32-2.tar.bz2 -C xen-patches-2.6.32-2
1.3.3 Apply Xen patches

Apply all the patches downloaded above following the patch number.

You may need to install patch if it isn’t installed:

# yum install patch

This patch.sh script can be used (we assume the patch and the kernel are in the same directory):

patch.sh:

#!/bin/bash
for P in `ls ../xen-patches-2.6.32-2/6*.patch1 | sort`
do
    patch -p1 -s -i $P
    if [ $? = 0 ]; then
        echo $P applied
    else
        echo "Error processing "$P
        exit 1
    fi
done

Put this script into Linux source directory(linux-2.6.32.13目录下) and execute:

$ sh ./patch.sh

The structure of these directories are as follows:

▲注:结构如上图。按照patch脚本,Linux-2.6.32.13 和xen=patches-2.6.32-2放在同一个目录。

1.3.4 Configure Xenified Linux kernel

A working configuration file that I used can be downloaded directly from here:

config-for-xenified-linux-2.6.32.13    

Just download this file, put it into the kernel source code file directory(linux-2.6.32.13目录下) and rename it to .config.

Other than use my configuration file, you can also configure it by yourself by using “make menuconfig”.

Make sure you build the kernel with these components enabled:

Processor type and features  --->
 [*] Symmetric multi-processing support
 [*] Support sparse irq numbering
 [*] Enable Xen compatible kernel
Device Drivers  --->
 XEN  --->
 [*] Privileged Guest (domain 0)
 <*> Backend driver support (NEW)
 <*>   Block-device backend driver (NEW)
 <*>   Block-device tap backend driver (NEW)
 < >   Block-device tap backend driver 2 (NEW)
 <*>   Network-device backend driver (NEW)
 (8)     Maximum simultaneous transmit requests (as a power of 2) (NEW)
 [ ]     Pipelined transmitter (DANGEROUS) (NEW)
 < >     Network-device loopback driver (NEW)
 < >   PCI-device backend driver (NEW)
 < >   TPM-device backend driver (NEW)
    SCSI backend driver (NEW)
    USB backend driver (NEW)
  Block-device frontend driver
  Network-device frontend driver
    Network-device frontend driver acceleration for Solarflare NICs (NEW)
  SCSI frontend driver (NEW)
  USB frontend driver (NEW)
 [*]   Taking the HCD statistics (for debug) (NEW)
 [ ]   HCD suspend/resume support (DO NOT USE) (NEW)
 <*> User-space granted page access driver (NEW)
 <*> Framebuffer-device frontend driver (NEW)
 <*>   Keyboard-device frontend driver (NEW)
 [*] Disable serial port drivers (NEW)
 <*> Export Xen attributes in sysfs (NEW)
 (256) Number of guest devices (NEW)
 Xen version compatibility (no compatibility code)  --->
 [*] Place shared vCPU info in per-CPU storage (NEW)
1.3.5 Build kernel (linux-2.6.32.13目录下)
$ make -jX

X can be two times of the number of the processor. We use this to let make invoke compilation work in X-wayparallel.

1.3.6 Install modules and kernel (linux-2.6.32.13目录下)
# make modules_install install
【这一步执行时间很长,中间有停顿现象】
1.4 Configure grub

Add one entry for Xen in /boot/grub/grub.conf. This is an example entry:

# vi /boot/grub/grub.conf

title Xen3.4.3- Xenified Linux 2.6.32.13

  root (hd0,0)

  kernel /xen-3.4.3.gz cOnsole=vga vga=ask noreboot

  module /vmlinuz-2.6.32.13 ro root=/dev/mapper/VolGroup-LogVol_root noiswmd LANG=en_US.UTF-8 SYSFOnT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us

  module /initramfs-2.6.32.13.img

The root and other parameters may be different depending on the configuration.

# 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,7)

#          kernel /vmlinuz-version ro root=/dev/sda11

#          initrd /initrd-[generic-]version.img

#boot=/dev/sda

default=3

timeout=5

splashimage=(hd0,7)/grub/splash.xpm.gz

hiddenmenu

title Xen 3.4.3 -Xenified Linux 2.6.32.13

        root (hd0,7)

        kernel /xen-3.4.3.gz cOnsole=vga vga=ask noreboot

        module  /vmlinuz-2.6.32.13 ro root=UUID=7329a86e-6254-48ab-a084-69fed3fc6881 nomodeset LANG=en_US.UTF-8 SYSFOnT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us rhgb quiet

        module /initramfs-2.6.32.13.img

title Fedora (2.6.32.26-175.fc12.x86_64)

        root (hd0,7)

        kernel /vmlinuz-2.6.32.26-175.fc12.x86_64 ro root=UUID=7329a86e-6254-48ab-a084-69fed3fc6881 nomodeset LANG=en_US.UTF-8 SYSFOnT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us rhgb quiet

        initrd /initramfs-2.6.32.26-175.fc12.x86_64.img

title Fedora (2.6.31.5-127.fc12.x86_64)

        root (hd0,7)

        kernel /vmlinuz-2.6.31.5-127.fc12.x86_64 ro root=UUID=7329a86e-6254-48ab-a084-69fed3fc6881 nomodeset LANG=en_US.UTF-8 SYSFOnT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us rhgb quiet

        initrd /initramfs-2.6.31.5-127.fc12.x86_64.img

title Other

        rootnoverify (hd0,0)

        chainloader +1

1.5 Make Xend and Xendomains services automatically start when system boots
# cd /etc/init.d/
# chkconfig --add xend
# chkconfig --add xendomains

Check whether Xend and Xendomains services are automatically started in level 3-5:

# chkconfig --list | grep xend

It should be like this:

xend               0:off    1:off    2:off    3:on    4:on    5:on    6:off
xendomains         0:off    1:off    2:off    3:on    4:on    5:on    6:off
注:XEN的安装到此即可,然后重启,选择【Xen 3.4.3 - Xenified Linux 2.6.32.13】启动项。启动过程会提示某些部件失败,不用理会,登陆Fedora即可。
1.6 Enjoy the fun now!

After booting the system, you can try to use xm to check xen info

# xm info

Then xm command can be used to start up DomUs.

[root@czm003fedora12 czm]# xm info

host                   : czm003fedora12

release                :2.6.32.13

version                : #1 SMP Sun Oct 7 08:30:28 HKT 2012

machine                : x86_64

nr_cpus                : 4

nr_nodes               : 1

cores_per_socket       : 2

threads_per_core       : 2

cpu_mhz                : 2266

hw_caps                : bfebfbff:28000800:00000000:00000740:0098e3bd:00000000:00000001:00000000

virt_caps              : hvm

total_memory           : 1970

free_memory            : 121

node_to_cpu            : node0:0-3

node_to_memory         : node0:121

xen_major              : 3

xen_minor              : 4

xen_extra              : .3

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

cc_compiler            : gcc version 4.4.4 20100630 (Red Hat4.4.4-10) (GCC)

cc_compile_by          : czm

cc_compile_domain      :

cc_compile_date        : Sun Oct  7 08:04:56 HKT 2012

xend_config_format     : 4

[root@czm003fedora12 czm]#

#xm list

[root@czm003fedora12 czm]# xm list

Name                          ID   Mem  VCPUs      State   Time(s)

Domain-0                      0    1824     4          r-----     80.2

[root@czm003fedora12 czm]#

至此,只是在物理PC上安装完XEN虚拟机监控器(可理解为宿主环境),要创建虚拟机还需要在宿主环境上上安装操作系统。


推荐阅读
  • 在Docker中,将主机目录挂载到容器中作为volume使用时,常常会遇到文件权限问题。这是因为容器内外的UID不同所导致的。本文介绍了解决这个问题的方法,包括使用gosu和suexec工具以及在Dockerfile中配置volume的权限。通过这些方法,可以避免在使用Docker时出现无写权限的情况。 ... [详细]
  • 本文介绍了Linux系统中正则表达式的基础知识,包括正则表达式的简介、字符分类、普通字符和元字符的区别,以及在学习过程中需要注意的事项。同时提醒读者要注意正则表达式与通配符的区别,并给出了使用正则表达式时的一些建议。本文适合初学者了解Linux系统中的正则表达式,并提供了学习的参考资料。 ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • 推荐系统遇上深度学习(十七)详解推荐系统中的常用评测指标
    原创:石晓文小小挖掘机2018-06-18笔者是一个痴迷于挖掘数据中的价值的学习人,希望在平日的工作学习中,挖掘数据的价值, ... [详细]
  • Java验证码——kaptcha的使用配置及样式
    本文介绍了如何使用kaptcha库来实现Java验证码的配置和样式设置,包括pom.xml的依赖配置和web.xml中servlet的配置。 ... [详细]
  • YOLOv7基于自己的数据集从零构建模型完整训练、推理计算超详细教程
    本文介绍了关于人工智能、神经网络和深度学习的知识点,并提供了YOLOv7基于自己的数据集从零构建模型完整训练、推理计算的详细教程。文章还提到了郑州最低生活保障的话题。对于从事目标检测任务的人来说,YOLO是一个熟悉的模型。文章还提到了yolov4和yolov6的相关内容,以及选择模型的优化思路。 ... [详细]
  • 云原生边缘计算之KubeEdge简介及功能特点
    本文介绍了云原生边缘计算中的KubeEdge系统,该系统是一个开源系统,用于将容器化应用程序编排功能扩展到Edge的主机。它基于Kubernetes构建,并为网络应用程序提供基础架构支持。同时,KubeEdge具有离线模式、基于Kubernetes的节点、群集、应用程序和设备管理、资源优化等特点。此外,KubeEdge还支持跨平台工作,在私有、公共和混合云中都可以运行。同时,KubeEdge还提供数据管理和数据分析管道引擎的支持。最后,本文还介绍了KubeEdge系统生成证书的方法。 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 本文讨论了Alink回归预测的不完善问题,指出目前主要针对Python做案例,对其他语言支持不足。同时介绍了pom.xml文件的基本结构和使用方法,以及Maven的相关知识。最后,对Alink回归预测的未来发展提出了期待。 ... [详细]
  • [译]技术公司十年经验的职场生涯回顾
    本文是一位在技术公司工作十年的职场人士对自己职业生涯的总结回顾。她的职业规划与众不同,令人深思又有趣。其中涉及到的内容有机器学习、创新创业以及引用了女性主义者在TED演讲中的部分讲义。文章表达了对职业生涯的愿望和希望,认为人类有能力不断改善自己。 ... [详细]
  • 知识图谱——机器大脑中的知识库
    本文介绍了知识图谱在机器大脑中的应用,以及搜索引擎在知识图谱方面的发展。以谷歌知识图谱为例,说明了知识图谱的智能化特点。通过搜索引擎用户可以获取更加智能化的答案,如搜索关键词"Marie Curie",会得到居里夫人的详细信息以及与之相关的历史人物。知识图谱的出现引起了搜索引擎行业的变革,不仅美国的微软必应,中国的百度、搜狗等搜索引擎公司也纷纷推出了自己的知识图谱。 ... [详细]
  • 本文介绍了Hyperledger Fabric外部链码构建与运行的相关知识,包括在Hyperledger Fabric 2.0版本之前链码构建和运行的困难性,外部构建模式的实现原理以及外部构建和运行API的使用方法。通过本文的介绍,读者可以了解到如何利用外部构建和运行的方式来实现链码的构建和运行,并且不再受限于特定的语言和部署环境。 ... [详细]
author-avatar
CCTV2财经2677
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有