码迷,mamicode.com
首页 > 其他好文 > 详细

xen安装(一)

时间:2015-09-08 16:49:21      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:xen是什么   xen的原理   xen部署安装   

一、近日接到CTO分下来任务,研发部经常使用一批机器来业务测试,准备几台性能好服务器放在IDC房做Linux虚拟化来接入使用。我第一时间想到就是用xen,以前看过这方面资料,但没运用在生产环境上,先从xen实施起,以后在利用openstack打造内部私有云。

 

二、以下回忆xen原理,具体原理,网上有很多资料查询的到

  虚拟化技术的分类:
     模拟:著名的模拟器,PearPC, Bochs, QEMU
     完全虚拟化:也称为native virtulization
                  两种加速方式:
                       BT
                           HVM
       VMware Workstation, VMware Server, Parallels Desktop, KVM, Xen(HVM)
 

    半虚拟化:para-virtualization
      xen, uml(user-mode linux)
 

    OS级别的虚拟化:
          OpenVZ, lxc
          Solaris Containers
          FreeBSD jails
 

    库虚拟化:
          wine

   应用程序虚拟化:
          jvm

 

    虚拟化网络:
         nat mode
         bridge mode
         routed mode
         isolation mode

 

 

Xen的工作模式:
     pv: 半虚拟化
     fv: 依赖于CPU的HVM
     pv on hvm: CPU完全虚拟化,但IO采用半虚拟化;

 

xen的使用方式:
     xen hypervisor
              硬件 --> 安装Linux --> 安装xen --> 修改grub,配置其内核为xen,而不再使用原Linux的内核(原Linux的内核和initramfs文件被当作xen的模块)--> 重新编译Linux内核,使得其能够运行于Dom0 --> 重启系统;
 

     DomU: 在Dom0使用工具创建虚拟机-->启动虚拟机-->安装操作系统;
 

     xenserver:
              citrix:
 

        xcp: xen cloud platform

 

        工具栈:xm/xend, xl, xapi/xe
              libvirt: virsh/libvirtd, virtmanager

 

二、操作系统

拿公司一台装有linux系统的物理来测试

[root@logicserver ~]# cat /etc/issue;uname -r
CentOS release 6.3 (Final)
Kernel \r on an \m
2.6.32-279.el6.x86_64

 

三、部署安装

[root@logicserver ~]# yum install centos-release-xen
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/metalink                                                                                                                                                                      | 4.8 kB     00:00     
 * base: mirrors.pubyun.com
 * epel: ftp.cuhk.edu.hk
 * extras: centos.ustc.edu.cn
 * updates: centos.ustc.edu.cn
epel                                                                                                                                                                               | 4.3 kB     00:00     
epel/primary_db                                                                                                                                                                    | 5.7 MB     00:13     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package centos-release-xen.x86_64 10:6-4.el6.centos will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================================================================================================
 Package                                                Arch                                       Version                                               Repository                                  Size
==========================================================================================================================================================================================================
Installing:
 centos-release-xen                                     x86_64                                     10:6-4.el6.centos                                     extras                                     4.9 k
Transaction Summary
==========================================================================================================================================================================================================
Install       1 Package(s)
Total download size: 4.9 k
Installed size: 1.3 k
Is this ok [y/N]: y
Downloading Packages:
centos-release-xen-6-4.el6.centos.x86_64.rpm                                                                                                                                       | 4.9 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 10:centos-release-xen-6-4.el6.centos.x86_64                                                                                                                                            1/1 
  Verifying  : 10:centos-release-xen-6-4.el6.centos.x86_64                                                                                                                                            1/1
Installed:
  centos-release-xen.x86_64 10:6-4.el6.centos                                                                                                                                                            
Complete!
[root@logicserver ~]# yum list xen*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.skyshe.cn
 * epel: ftp.cuhk.edu.hk
 * extras: centos.ustc.edu.cn
 * updates: centos.ustc.edu.cn
Xen4CentOS                                                                                                                                                                         | 3.4 kB     00:00     
Xen4CentOS/primary_db                                                                                                                                                              | 150 kB     00:00     
Available Packages
xen.x86_64                                                                                            4.4.2-7.el6                                                                               Xen4CentOS
xen-debuginfo.x86_64                                                                                  4.1.2-20.el6                                                                              el6-xen   
xen-devel.x86_64                                                                                      4.4.2-7.el6                                                                               Xen4CentOS
xen-doc.x86_64                                                                                        4.4.2-7.el6                                                                               Xen4CentOS
xen-hypervisor.x86_64                                                                                 4.4.2-7.el6                                                                               Xen4CentOS
xen-libs.x86_64                                                                                       4.4.2-7.el6                                                                               Xen4CentOS
xen-licenses.x86_64                                                                                   4.4.2-7.el6                                                                               Xen4CentOS
xen-ocaml.x86_64                                                                                      4.4.2-7.el6                                                                               Xen4CentOS
xen-ocaml-devel.x86_64                                                                                4.4.2-7.el6                                                                               Xen4CentOS
xen-runtime.x86_64                                                                                    4.4.2-7.el6                                                                               Xen4CentOS
xenserverjava.noarch                                                                                  5.6.100.1-1.el6                                                                           epel      
xenserverjava-javadoc.noarch                                                                          5.6.100.1-1.el6                                                                           epel
[root@logicserver ~]# ll /boot/xen*
-rw-r--r--. 1 root root   855600 8月   3 20:18 /boot/xen-4.4.2-7.el6.gz
lrwxrwxrwx. 1 root root       18 9月   8 13:20 /boot/xen-4.4.gz -> xen-4.4.2-7.el6.gz
lrwxrwxrwx. 1 root root       18 9月   8 13:20 /boot/xen.gz -> xen-4.4.2-7.el6.gz
-rw-r--r--. 1 root root 15925635 8月   3 20:18 /boot/xen-syms-4.4.2-7.el6

 

 安装完支持 Xen 的 Linux 内核后需要加新条目到 grub.conf,以便系统能默认启动带 Xen 的 Linux 内核(而不是常规 Linux 内核),这个操作可以通过 grub-bootxen.sh 自动完成,弄完后打开 grub.conf 文件再次确认一下:

root@logicserver ~]# vim /etc/grub.conf
# 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/sda2
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.18.17-13.el6.x86_64)
        root (hd0,0)
        kernel /xen.gz dom0_mem=1024M,max:1024M loglvl=all guest_loglvl=all
        module /vmlinuz-3.18.17-13.el6.x86_64 ro root=UUID=17793804-41a2-4cec-b58d-ffec3766aaf3 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
        module /initramfs-3.18.17-13.el6.x86_64.img
title CentOS (2.6.32-279.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=UUID=17793804-41a2-4cec-b58d-ffec3766aaf3 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-279.el6.x86_64.img

 

重启机器reboot

[root@logicserver ~]# service xend start
启动 xend 守护进程:                                       [确定] 

[root@logicserver ~]# xm info
WARNING: xend/xm is deprecated.
host                   : logicserver
release                : 3.18.17-13.el6.x86_64
version                : #1 SMP Tue Jul 21 17:17:17 UTC 2015
machine                : x86_64
nr_cpus                : 2
nr_nodes               : 1
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 2993
hw_caps                : bfebfbff:28100800:00000000:00007f00:059ae3bf:00000000:00000001:00000281
virt_caps              : hvm
total_memory           : 8068
free_memory            : 6951
free_cpus              : 0
xen_major              : 4
xen_minor              : 4
xen_extra              : .2-7.el6
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          : Thu Apr 23 15:06:13 2015 +0100 git:8621d99-dirty
xen_commandline        : dom0_mem=1024M,max:1024M loglvl=all guest_loglvl=all
cc_compiler            : gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)
cc_compile_by          : mockbuild
cc_compile_domain      : centos.org
cc_compile_date        : Mon Aug  3 12:17:58 UTC 2015
xend_config_format     : 4
[root@logicserver ~]# xm list
WARNING: xend/xm is deprecated.
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  1021     2     r-----     94.7

另外xl不需要xend服务的,所以在使用它前,需要把xend服务停掉

[root@logicserver ~]# service xend stop
正在关闭 xend 守护进程:                                   [确定] 

[root@logicserver ~]# xl info
host                   : logicserver
release                : 3.18.17-13.el6.x86_64
version                : #1 SMP Tue Jul 21 17:17:17 UTC 2015
machine                : x86_64
nr_cpus                : 2
max_cpu_id             : 1
nr_nodes               : 1
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 2993
hw_caps                : bfebfbff:28100800:00000000:00007f00:059ae3bf:00000000:00000001:00000281
virt_caps              : hvm
total_memory           : 8068
free_memory            : 6951
sharing_freed_memory   : 0
sharing_used_memory    : 0
outstanding_claims     : 0
free_cpus              : 0
xen_major              : 4
xen_minor              : 4
xen_extra              : .2-7.el6
xen_version            : 4.4.2-7.el6
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          : Thu Apr 23 15:06:13 2015 +0100 git:8621d99-dirty
xen_commandline        : dom0_mem=1024M,max:1024M loglvl=all guest_loglvl=all
cc_compiler            : gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)
cc_compile_by          : mockbuild
cc_compile_domain      : centos.org
cc_compile_date        : Mon Aug  3 12:17:58 UTC 2015
xend_config_format     : 4


[root@logicserver ~]# xl list
Name                                        ID   Mem VCPUs State Time(s)
Domain-0                                     0  1021     2     r-----     106.8

 

 

本文出自 “散人” 博客,请务必保留此出处http://zouqingyun.blog.51cto.com/782246/1692781

xen安装(一)

标签:xen是什么   xen的原理   xen部署安装   

原文地址:http://zouqingyun.blog.51cto.com/782246/1692781

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!