一、xen介绍

xen使得用户可以创建更多的虚拟机,每一个虚拟机都是运行在同一个操作系统上的实例。

Xen虚拟机有两种运行方式:完全虚拟化(full virtualization)和半虚拟化(para virtualization)。
1、完全虚拟化提供底层物理系统的全部抽象化,且创建一个新的虚拟系统,客户机操作系统可以在里面运行。不需要对客户机操作系统或者应用程序进行修改(客户机操作系统或者应用程序像往常一样运行,意识不到虚拟环境的存在)。可以创建Linux、FreeBSD和Windows客户机。
2、半虚拟化需要对运行在虚拟机上的客户机操作系统进行修改(这些客户机操作系统会意识到它们运行在虚拟环境里)并提供相近的性能,但半虚拟化的性能要比完全虚拟化更优越。支持RHEL4.5以上版本的客户机。

二、xen安装

1、确定你的服务器是否支持完全虚拟化或者半虚拟化

如果有 pae标志出现的话,就表示你的处理器支持半虚拟化。对Intel的CPU,如果有 vmx标志出现的话,就表示你的处理器支持完全虚拟化。 对AMD的CPU,如果有 svm标志出现的话,就表示你的处理器支持完全虚拟化。

注:某些Intel服务器,默认"Virtualizaton Technology"功能没有打开,需要到BIOS中将其打开。

 
  
  1. [root@localhost ~]# grep flags /proc/cpuinfo   
  2. flags       : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss nx lm constant_tsc up ida nonstop_tsc pni ssse3 cx16 sse4_1 lahf_lm [8] 

2、 检查是否已经安装xen

查看是否已经安装了xen或者已经安装的xen版本以及linux内核是否有针对xen的补丁。

 
  
  1. [root@localhost ~]# rpm -qa | grep xen  
  2. [root@localhost ~]# ls /boot/  
  3. config-2.6.18-194.el5  grub  initrd-2.6.18-194.el5.img  lost+found  symvers-2.6.18-194.el5.gz  System.map-2.6.18-194.el5  vmlinuz-2.6.18-194.el5  
  4. [root@localhost ~]#  

3、安装

3.1、在redhat linux下使用yum出现:Loaded plugins: rhnplugin, security,解决方法:

 
  
  1. --检查yum是否安装,默认都是安装的  
  2. [root@oraweb yum.repos.d]# rpm -qa |grep yum  
  3. yum-updatesd-0.9-2.el5  
  4. yum-metadata-parser-1.1.2-3.el5  
  5. yum-security-1.1.16-13.el5  
  6. yum-3.2.22-26.el5  
  7. --编辑配置文件,配置yum更新源  
  8. [root@oraweb yum.repos.d]# vi /etc/yum.repos.d/CentOS-Base.repo  
  9. [base]  
  10. name=CentOS-5-Base  
  11. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&repo=os 
  12. #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/  
  13. baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/  
  14. gpgcheck=0 
  15. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5  
  16. #released updates  
  17. [update]  
  18. name=CentOS-5-Updates  
  19. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates 
  20. baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/  
  21. gpgcheck=0 
  22. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5  
  23. #packages used/produced in the build but not released  
  24. [addons]  
  25. name=CentOS-5-Addons  
  26. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons 
  27. baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/  
  28. gpgcheck=0 
  29. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5  
  30. #additional packages that may be useful  
  31. [extras]  
  32. name=CentOS-5-Extras  
  33. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras 
  34. baseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/  
  35. gpgcheck=0 
  36. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5  
  37. #additional packages that extend functionality of existing packages  
  38. [centosplus]  
  39. name=CentOS-5-Plus  
  40. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus 
  41. baseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/  
  42. gpgcheck=0 
  43. enabled=0 
  44. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5  
  45. #contrib - packages by Centos Users  
  46. [contrib]  
  47. name=CentOS-5-Contrib  
  48. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib 
  49. baseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/  
  50. gpgcheck=0 
  51. enabled=0 
  52. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5  
  53. # vi dag.repo  
  54. [dag]  
  55. name=Dag RPM Repository for RHEL5  
  56. baseurl=http://ftp.riken.jp/Linux/dag/redhat/el5/en/$basearch/dag/  
  57. enabled=1 
  58. gpgcheck=0 
  59. gpgkey=http://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt  
  60. --导入key  
  61. [root@oraweb yum.repos.d]# rpm --import http://ftp.sjtu.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5