Xen安裝部署

 1.    硬件要求

硬件需要滿足如下要求:

1. 至少2G內存

    2. 6G的硬盤空間

    3. 對於全虛擬化需要CPU支持虛擬化技術

 

使用如下命令確認CPU的參數設置

  1. [root@test-19-227 ~]# cat /proc/cpuinfo | grep vmx 
  2.  
  3. flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx pdpe1gb rdtscp lm constant_tsc ida nonstop_tsc arat pni monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm 

若要支持全虛擬機,則需要打開VT功能,如果沒有開啓VT,則需要進BIOS開啓該功能

2.    使用Yum安裝Xen

需要安裝Xen kernel-Xen軟件包

Xen包:包含了Xen hypervisor Xen tools

   kernel-xen: 是一個可以運行在Xen hypervisor虛擬機的linux內核

  1. [root@test-19-227 ~]# yum install xen  kernel-xen 
其他推薦工具:

python-virtinst:提供virt-install命令安裝虛擬機

libvirt-python:提供了用python語言腳本管理Xen的接口

libvirt:提供了命令行工具管理Xen虛擬機

virt-manager:提供了圖形化管理Xen虛擬機的工具

bridge-utils :該程序包存放的是用於配置以太網橋的實用程序,以太網橋的作用是將多個以太網設備連在一起。

Xen-libs :該程序包存放的是Xen的管理程序所需的程序庫。 

3.    編輯grub,使用Xen內核啓動

修改前的grub文件:

  1. [root@test-19-227 ~]# vim /etc/grub.conf 
  2.  
  3.     # grub.conf generated by anaconda 
  4.  
  5.     # 
  6.  
  7.     # Note that you do not have to rerun grub after making changes to this file 
  8.  
  9.     # NOTICE:  You have a /boot partition.  This means that 
  10.  
  11.     #          all kernel and initrd paths are relative to /boot/, eg. 
  12.  
  13.     #          root (hd0,0) 
  14.  
  15.     #          kernel /vmlinuz-version ro root=/dev/vg_root/lv_root 
  16.  
  17.     #          initrd /initrd-version.img 
  18.  
  19.     #boot=/dev/sda 
  20.  
  21.     default=1 
  22.  
  23.     timeout=5 
  24.  
  25.     splashimage=(hd0,0)/grub/splash.xpm.gz 
  26.  
  27.     hiddenmenu 
  28.  
  29.     title CentOS (2.6.18-238.12.1.el5xen
  30.  
  31.         root (hd0,0
  32.  
  33.         kernel /xen.gz-2.6.18-238.12.1.el5 
  34.  
  35.         module /vmlinuz-2.6.18-238.12.1.el5xen ro root=/dev/vg_root/lv_root 
  36.  
  37.         module /initrd-2.6.18-238.12.1.el5xen.img 
  38.  
  39.     title CentOS (2.6.18-194.el5
  40.  
  41.         root (hd0,0
  42.  
  43.         kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/vg_root/lv_root 
  44.  
  45.         initrd /initrd-2.6.18-194.el5.img 

注意default=1,默認情況下用第二個內核啓動,即使用title CentOS (2.6.18-194.el5)啓動;

應該使用title CentOS (2.6.18-238.12.1.el5xen)啓動,所以將default的值改爲0

修改後的grub文件:

  1. # grub.conf generated by anaconda 
  2. # 
  3. # Note that you do not have to rerun grub after making changes to this file 
  4. # NOTICE:  You have a /boot partition.  This means that 
  5. #          all kernel and initrd paths are relative to /boot/, eg. 
  6. #          root (hd0,0) 
  7. #          kernel /vmlinuz-version ro root=/dev/vg_root/lv_root 
  8. #          initrd /initrd-version.img 
  9. #boot=/dev/sda 
  10. default=0 
  11. timeout=5 
  12. splashimage=(hd0,0)/grub/splash.xpm.gz 
  13. hiddenmenu 
  14. title CentOS (2.6.18-238.12.1.el5xen
  15.         root (hd0,0
  16.         kernel /xen.gz-2.6.18-238.12.1.el5 
  17.         module /vmlinuz-2.6.18-238.12.1.el5xen ro root=/dev/vg_root/lv_root 
  18.         module /initrd-2.6.18-238.12.1.el5xen.img 
  19. title CentOS (2.6.18-194.el5
  20.         root (hd0,0
  21.         kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/vg_root/lv_root 
  22.         initrd /initrd-2.6.18-194.el5.img 

啓動參數的含義:

  1. title CentOS (2.6.18-238.12.1.el5xen)     ##定義了內核的名稱,該名稱將在引導菜單時顯示 
  2. root (hd0,0)    ##定義了引導系統的根分區 
  3. kernel /xen.gz-2.6.18-238.12.1.el5    ##指定了需要引導的內核 
  4. module /vmlinuz-2.6.18-238.12.1.el5xen ro root=/dev/vg_root/lv_root   ##定義了用於DOM0的內核 
  5. module /initrd-2.6.18-238.12.1.el5xen.img   ##定義了內核初始化時加載的初始RAM磁盤鏡像 

4.    重啓機器,檢查是否是XEN內核

重啓前使用的內核:

  1. [root@test-19-227 ~]# uname  -rm 
  2. 2.6.18-194.el5 x86_64  

重啓後使用的內核:

  1. [root@test-19-227 ~]# uname  -rm 
  2. 2.6.18-238.12.1.el5xen x86_64  

檢查xend是否運行

  1. [root@test-19-227 ~]# ps -ef|grep xend 
  2. root      5431     1  0 15:04 ?        00:00:00 /usr/bin/python /usr/sbin/xend start 
  3. root      5432  5431  0 15:04 ?        00:00:00 /usr/bin/python  
  4. root      5882  5846  0 15:09 pts/0    00:00:00 grep xend 

 檢查domain0是否運行

  1. [root@test-19-227 ~]# xm list 
  2. Name                                      ID Mem(MiB) VCPUs State   Time(s) 
  3. Domain-0                                   0    15651    16 r-----     32.7 

檢查log輸出

  1. [root@test-19-227 xen]# more xend-debug.log  
  2. Nothing to flush. 
  3. Nothing to flush 

5.    簡單製作網絡安裝環境

centos的鏡像文件掛載到服務器上,並且將文件複製到配置好的HTTP目錄下即可。

6.    配置Xendvnc服務

安裝vncvnc server

  1. [root@test-19-227 ~]# yum install vnc vnc-server 

配置xend,配置如下選項

  1. [root@test-19-227 xen]# vim /etc/xen/xend-config.sxp 
  2. (vnc-listen '192.168.19.227'
  3.  (vncpasswd ''

重新啓動Xend,如果重啓不成功則需要重啓機器

  1. [root@test-19-227 xen]# service xend restart 

7.    virt-install命令全虛擬化安裝CentOS客戶機

  1. [root@test-19-227 CentOS]# virt-install -n Centos_xen -r 8196  --vcpus=16  -f /opt/xen_centos/Centos_xen.disk -s 120 -v --os-type=linux --os-variant=rhel5       -l http://192.168.19.215/centos/ 

使用VNC客戶端連接,開始安裝 

下面的過程和正常安裝系統是一樣的

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章