Red Hat Training
A Red Hat training course is available for Red Hat Enterprise Linux
Virtualization
A reference guide for virsch, xm, vmm and xend.
版 2.0
摘要
Red Hat Enterprise Linux
及其元件 虛擬化指南
,將回報呈送到 Bugzilla(http://bugzilla.redhat.com/bugzilla/
)。
章 1. Red Hat 虛擬化系統架構
章 2. 作業系統支援
- Intel VT-x 或是 AMD-V Pacifica 以及 Vanderpool 技術來執行完整的虛擬化與半虛擬化。
- ia64 的 Intel VT-i
- Linux 與 UNIX 作業系統,包括 NetBSD、FreeBSD、以及 Solaris。
- Microsoft Windows as an unmodified guest operating system with Intel Vanderpool or AMD's Pacifica technology.
grep vmx /proc/cpuinfo
flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
grep svm /proc/cpuinfo cat /proc/cpuinfo | grep svm
flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dt acpi mmx fxsr sse sse2 ss ht tm syscall nx mmtext fxsr_opt rdtscp lm 3dnowext pni cx16 lahf_lm cmp_legacy svm cr8_legacy
注意
章 3. 硬體支援
- Celeron
- Pentium II
- Pentium III
- Pentium IV
- Xeon
- AMD Athlon
- AMD Duron
mem=32G
。這項範例顯示了如何在 grub.conf
這個檔案中使用正確的參數:
title Red Hat Enterprise Linux Server (2.6.18-4.elxen) root (hd0, 0) kernel /xen.gz-2.6.18-4-el5 mem=32G module /vmlinuz -2.6.18-4.el5xen ro root=LABEL=/ module /initrd-2.6.18-4.el5xen.img
grep pae /proc/cpuinfo
flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 mmx fxsr sse syscall mmtext 3dnowext 3dnow up ts
章 4. Red Hat 虛擬化系統需求
- 一份能運作的 Red Hat RHEL 5 Linux 發行
- 一份能運作的 GRUB 開機管理程式
- Root 存取
- 一個 P6 等級(或是更早期)的處理器
- Linux 橋接公用程式
- Linux hotplug 系統
- zlib 開發安裝
- Python 2.2 runtime
- initscripts
注意
xen-ia64-guest-firmware
package to run a fully virtualized guest. This package is provided in the Supplementary CD and is not installed by default.
章 5. 啟動系統
service xend start
chkconfig xend
來使 xend
在 boot time(啟動時間)時生效。
章 6. 設定 GRUB
/boot/grub/grub.conf
) is used to create a list of operating systems to boot in GRUB's menu interface. When you install the kernel-xen RPM, a post script adds kernel-xen entries to the GRUB configuration file. You can edit the grub.conf
file and enable the following GRUB parameter:
title Red Hat Enterprise Linux Server (2.6.18-3.el5xen) root (hd0; 0) kernel /xen.gz.-2.6.18-3.el5 module /vmlinuz-2.6..18-3.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet module /initrd-2.6.18-3. el5xenxen.img
initrd
映像檔,以及 Linux 核心。因為核心的項目位於其它項目的上方,所以核心會先載入記憶體中。接著開機管理程式會傳送(與接收)指令列引數至超管理器與 Linux 核心(或由它們接收指令列引數)。這項範例顯示了您該如何將 Domain0 linux 的核心記憶體限制為 800MB:
title Red Hat Enterprise Linux Server (2.6.18-3.el5xen) root (hd0; 0) kernel /xen.gz.-2.6.18-3.el5 dom0_mem=800M module /vmlinuz-2.6..18-3.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet module /initrd-2.6.18-3. el5xenxen.img
mem
com1=115200, 8n1
dom0_mem
dom0_max_vcpus
acpi
/* **** Linux config options: propagated to domain0 ****/ /* "acpi=off": Disables both ACPI table parsing and interpreter. */ /* "acpi=force": Overrides the disable blacklist. */ /* "acpi=strict": Disables out-of-spec workarounds. */ /* "acpi=ht": Limits ACPI from boot-time to enable HT. */ /* "acpi=noirq": Disables ACPI interrupt routing. */
noacpi
章 7. 啟動一個客座端網域
xm
應用程式來啟動客座端網域。您也能使用 virsh
與 Virtual Machine Manager 來啟動客座端。要啟動一個客座端網域的先決條件就是要先安裝一台客座端主機。以下的範例使用了 xm
來建立次指令:
# xm create -c guestdomain1
guestdomain1
代表您所啟動的網域的設定檔案。 -c
選項則會在啟動以後連接至實際的主機。
章 8. 在開機時啟動與停止一個網域
/etc/xen/ directory.
中。所有您想在啟動時間開啟的網域都必須以符號連結(symlinked)至 /etc/xen/auto
。
chkconfig xendomains on
chkconfig xendomains on
這項指令不會自動的開啟網域,而是在下次啟動時再開啟網域。
chkconfig xendomains off
chkconfig xendomains off
這項指令則會在下次啟動時將網域關閉。
章 9. 設定檔案
/etc/xen
directory.
表格 9.1. Red Hat 虛擬化設定檔案
項目 | 描述 |
---|---|
pae
|
指定實體位址延伸的設定資料。
|
apic
|
指定進階的可編程式的中斷控制器組態資料。
|
memory
|
指定記憶體大小為百萬位元組(MB)。
|
vcpus
|
指定虛擬 CPU 的數量。
|
console
|
指定將網域主控台輸出的埠號(port numbers)。
|
nic
|
指定虛擬網路介面的數量。
|
vif
|
Lists the randomly-assigned MAC addresses and bridges assigned to use for the domain's network addresses.
|
disk
|
列出要導出至網域的區塊裝置,並且將實體裝置導出至唯讀存取的網域。
|
dhcp
|
使用 DHCP 來使網路連結有效。
|
netmask
|
指定已設定的 IP 網路遮罩。
|
gateway
|
指定已設定的 IP gateways(閘道)。
|
acpi
|
Red Hat 虛擬化指定進階的設定強化介面設定資料
|
章 10. 管理中央處理器
章 11. 遷移一個網域
xm migrate domain-id [destination domain]
xm migrate domain-id -l [destination domain]
章 12. 在網路上的使用設定
dom0
by a point to point link. These devices are vif
<domid>
and <vifid>
. vif1.0
for the first interface in domain 1; vif3.1
for the second interface in domain 3.
network-bridge
and vif-bridge
. xend calls these scripts when certain events occur. Arguments can be passed to the scripts to provide additional contextual information. These scripts are located in the /etc/xen/scripts
directory. You can change script properties by modifying the xend-config.sxp configuration file located in the /etc/xen
directory.
network-bridge
— 當 xend 啟動或者是停止後,這個 script 便會隨著它開啟或者是關閉虛擬網路。之後設定的初始化便會建立 xen—br0
這個橋接器然後將 eth0
移動至這個橋接器上並隨著更改路由的選擇。當 xend 最後終於跳出之後,它就會將這個橋接器刪除掉然後移除 eth0
,並由此來復原至原本的 IP 以及選路設定。
vif-bridge
這個 script。它能設定防火牆的規則,並且也能將 vif
附加至適當的橋接器上。
network-route
、network-nat
、vif-route,
、以及 vif-nat
。或是這些 script 也能以自定的變體來替代。
章 13. 提升 Domain0 的安全性
- 所執行的服務數量愈少愈好。您不會希望將太多的工作與服務加入 domain0。愈少物件在 domain0 上執行,安全性就愈高。
- 啟動 SeLINUX 來協助保全 domain0。
- 請利用防火牆來限制 domain0 的流量。您能夠以預設的拒絕規定來設置一道防火牆並且協助防止 domain0 受到攻擊。限制網路表面的服務其實也是很重要的。
- 請不要允許普通使用者存取 domain0。假如您允許普通使用者存取 domain0 的話,這可能會危及 domain0 的安全性而且讓它變得易受攻擊。請記得,domain0 是有特權的,假如授權給沒有特權的帳號可能會危害到並且降低安全性。
章 14. 儲存空間
章 15. 使用 virsh 來管理虛擬主機
xend/qemu
,您應該啟用 xend/qemu
來執行服務。在您修改過對應設定檔後,重新啟動系統,然後 xend/qemu
便會以服務執行。您可以使用 virsh 來 script vm工作。就如 xm 工具,在指令提示符號下執行 virsh。
15.1. 連接至管理程序
virsh connect <name>
<name>
is the machine name of the hypervisor. If you want to initiate a read—only connection, append the above command with —readonly
.
15.2. 建立虛擬主機
virsh create <path to XML configuration file>
15.3. 設定 XML 傾印
virsh dumpxml [domain-id | domain-name | domain-uuid]
stdout
. If you save the data to a file, you can use the create
option to recreate the virtual machine.
15.4. 擱置虛擬主機
virsh suspend [domain-id | domain-name |domain-uuid]
resume
option.
15.5. 繼續虛擬主機
virsh resume [domain-id | domain-name | domain-uuid]
擱置
與 繼續
循環。
15.6. 儲存虛擬主機
virsh save [domain-name][domain-id | domain-uuid][filename]
restore
option.
15.7. 回復虛擬主機
virsh save
option:
virsh restore [filename]
15.8. 關閉虛擬主機
virsh shutdown [domain-id | domain-name | domain-uuid]
xmdomain.cfg
檔的on_shutdown
參數來控制重新啟動虛擬主機的運轉狀態。
15.9. 重新啟動虛擬主機
virsh reboot [domain-id | domain-name | domain-uuid]
xmdomain.cfg
檔的on_reboot
參數來控制重新啟動虛擬主機的運轉狀態。
15.10. 終止網域
virsh destroy [domain-name | domain-id | domain-uuid]
destroy
option only when the virtual machine's operating system is non-responsive. For a paravirtualized virtual machine, you should use the shutdown
option.
15.11. 將網域名稱轉變為網域 ID
virsh domid [domain-name | domain-uuid]
15.12. 將網域 ID 轉變為網域名稱
virsh domname [domain-name | domain-uuid]
15.13. 將網域名稱轉變為 UUID
virsh domuuid [domain-id | domain-uuid]
15.14. 顯示虛擬主機資訊
virsh dominfo [domain-id | domain-name | domain-uuid]
15.15. 顯示節點資訊
virsh nodeinfo
CPU model x86_64 CPU (s) 8 CPU frequency 2895 Mhz CPU socket(s) 2 Core(s) per socket 2 Threads per core: 2 Numa cell(s) 1 Memory size: 1046528 kb
15.16. 顯示虛擬主機
virsh list domain-name [ ——inactive | —— -all]
——inactive
選項列出非啟用的網域(已定義但尚未啟用的網域)。— -all
domain 列出所有的網域,不論啟用與否。輸出因該如下列範例:
ID Name State ———————————————— 0 Domain0 running 1 Domain202 paused 2 Domain010 inactive 3 Domain9600 crashed
running lists domains currently active on the CPU blocked lists domains that are blocked paused lists domains that are suspended shutdown lists domains that are in process of shutting down shutoff lists domains that are completely down. crashed lists domains that are crashed
15.17. 顯示虛擬 CPU 資訊
virsh vcpuinfo [domain-id | domain-name | domain-uuid]
15.18. 設定虛擬 CPU 相似性
virsh vcpupin [domain-id | domain-name | domain-uuid] [vcpu] , [cpulist]
[vcpu]
為虛擬 VCPU 編號,而 [cpulist]
列出 CPU 的實體編號。
15.19. 設定虛擬 CPU 計數
virsh setvcpus [domain-name | domain-id | domain-uuid] [count]
15.20. 設定記憶體設定
virsh setmem [domain-id | domain-name] [count]
[count]
in kilobytes. Note that the new count cannot exceed the amount you specified when you created the Virtual Machine. Values lower than 64 MB probably won't work. You can adjust the Virtual Machine memory as necessary.
15.21. 設定最大記憶體
virsh setmaxmem [domain-name | domain-id | domain-uuid] [count]
15.22. Managing Virtual Networks
virsh net-list
[root@domain ~]# virsh net-list Name State Autostart ----------------------------------------- default active yes vnet1 active yes vnet2 active yes
virsh net-dumpxml [vnet name]
[root@domain ~]# virsh net-dumpxml vnet1 <network> <name>vnet1</name> <uuid>98361b46-1581-acb7-1643-85a412626e70</uuid> <forward dev='eth0'/> <bridge name='vnet0' stp='on' forwardDelay='0' /> <ip address='192.168.100.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.100.128' end='192.168.100.254' /> </dhcp> </ip> </network>
virsh net-autostart [network name]
— Autostart a network specified as [network name]virsh net-create [XML file]
— Generates and starts a new network using a preexisting XML filevirsh net-define [XML file]
— Generates a new network from a preexisting XML file without starting itvirsh net-destroy [network name]
— Destroy a network specified as [network name]virsh net-name [network UUID]
— Convert a specified [network UUID] to a network namevirsh net-uuid [network name
— Convert a specified [network name] to a network UUIDvirsh net-start [name of an inactive network]
— Starts a previously undefined inactive networkvirsh net-undefine [name of an inactive network]
— Undefine an inactive network
章 16. 使用 xend 虛擬主機來進行管理
etc/xen
目錄中的 xend-config.sxp
設定檔,來指定作業參數。下列為能在 xend-config.sxp
設定檔中啟用與停用的參數:
表格 16.1. Red hat 虛擬化 xend 設定參數
項目 | 性質 |
---|---|
console-limit
|
Determines the console server's memory buffer limit and assigns values on a per-domain basis
|
min-mem
|
決定預留於 domain0 (如果輸入為 0,則數值不會改變)的最小數值(以 megabyte 為單位)
|
dom0 cpus
|
決定 domain0 (預設上,最少會指定一個 CPU)所要使用的 CPU 數量
|
enable-dump
|
決定在發生當機時啟用傾印(預設為 0)
|
external-migration-tool
|
決定用來對應外部裝置移植的 script 或應用程式(script 必須置於
etc/xen/scripts/external-device-migrate )
|
logfile
|
決定登錄檔的位置(預設為
/var/log/xend.log )
|
loglevel
|
過濾登錄模式數值:DEBUG、INFO、WARNING、ERROR 或 CRITICAL(預設為 DEBUG)
|
network-script
|
決定用來啟用網路環境的 script(script 必須置於
etc/xen/scripts 目錄中)
|
xend-http-server
|
啟用 http 數據包管理伺服器(預設為無)
|
xend-unix-server
|
啟用 unix 網域承口伺服器(承口伺服器是通訊終點,用來因應的層級網路連接並接受或拒絕進入連線)
|
xend-relocation-server
|
啟用重置的伺服器來跨主機移植(預設為無)
|
xend-unix-path
|
決定
xend-unix-server 指令輸出資料的位置(預設為 var/lib/xend/xend-socket )
|
xend-port
|
決定 http 管理伺服器所使用的埠(預設為 8000)
|
xend-relocation-port
|
決定重置伺服器所使用的埠(預設為 8002)
|
xend-relocation-address
|
決定虛擬主機位置,並准許系統移植
|
xend-address
|
決定網域承口伺服器結合的位置。
|
service xend start
service xend stop
service xend restart
service xend status
章 17. 使用虛擬主機管理程式(Virtual Machine Manager)來管理虛擬主機
17.1. 虛擬主機管理程式架構
17.2. 開放連接視窗
test:///default
in the URL field beneath. Once in test mode, you can connect to a libvirt dummy hypervisor. Note that although the Remote Xen host screen is visible, the functionality to connect to such a host is not implemented into Red Hat Enterprise Linux 5.1.

圖形 17.1. Virtual Machine Manager Connection window
17.3. 虛擬主機管領程式視窗

圖形 17.2. Virtual Machine Manager main window
17.4. 虛擬主機詳細資料視窗

圖形 17.3. Virtual Machine Manager Details window
17.5. 虛擬主機圖形主控台

圖形 17.4. 圖形主控台視窗
17.6. Starting the Virtual Machine Manager
應用程式
選單,點選 系統工具
,然後在點選 虛擬主機管理員
來啟始虛擬主機管理員程序。

圖形 17.5. Starting the Virtual Machine Manager
17.7. 新增新的虛擬主機
- 建立新網域。
- Configure or adjust a domain's resource allocation and virtual hardware.
- 總結執行即時工作的網域與資源利用之數據。
- 持續顯示表示性能與資源利用的圖形。
- 使用內嵌 VNC 客戶端瀏覽器,因此可以將全圖形主控台展現於客座端網域。
注意
過程 17.1. 建立客座端作業系統
- 在 應用程式選單,點選 系統工具 然後點選 虛擬主機管理員。顯示虛擬主機管理員主視窗。
圖形 17.6. Virtual Machine Manager window
- 在 檔案 選單,點選 新主機。
圖形 17.7. 選擇新主機
顯示建立新虛擬系統導引。 - Click Forward.
圖形 17.8. 建立新虛擬系統導引
- Enter the name of the new virtual system and then click Forward.
圖形 17.9. 替虛擬系統取名
- 輸入安裝媒體的位置。Kickstart 檔案的位置為非必選。然後點 下一步。
圖形 17.10. 定位安裝媒體
- 將檔案安裝至實體硬碟分割區,或安裝至虛擬檔案系統。
注意
下列為將檔案安裝至虛擬系統之範例。SELinux policy only allows xen disk images to reside in/var/lib/xen/images
.Open a terminal and create the /xen directory and set the SELinux policy with the commandrestorecon -v /xen
. Specify your location and the size of the virtual disk, then click Forward.圖形 17.11. 指定儲存空間
- Select memory to allocate the guest and the number of virtual CPUs then click Forward.
圖形 17.12. 設定記憶體與 CPU
- Select Forward to open a console and the files start to install.
圖形 17.13. 設定記憶體與 CPU
- 在提供的視窗內完成安裝過程。
圖形 17.14. 安裝過程開始…
警告
When installing Red Hat Enterprise Linux 5.1 on a fully virtualized guest, do not use thekernel-xen
kernel. Using this kernel on fully virtualized guests can cause your system to hang.If you are using an Installation Number when installing Red Hat Enterprise Linux 5.1 on a fully virtualized guest, be sure to deselect theVirtualization
package group during the installation. TheVirtualization
package group option installs thekernel-xen
kernel.Note that paravirtualized guests are not affected by this issue. Paravirtualized guests always use thekernel-xen
kernel. - Type
xm create -c xen-guest
to start the Red Hat Enterprise Linux 5.1 guest. Right click on the guest in the Virtual Machine Manager and choose Open to open a virtual console.圖形 17.15. Red Hat Enterprise Linux 5.1 (guest)
- 輸入使用者名稱與密碼來繼續使用虛擬主機管理員。
17.8. 回復已儲存的主機
- 在 檔案 選單,選取 回復並儲存主機
圖形 17.16. Restoring a Virtual Machine
- 顯示回復虛擬主機主視窗。
圖形 17.17. 點選已儲存的虛擬主機程序
- 導引至正確的目錄然後選取已儲存的程序檔案。
- 點選 開啟。

圖形 17.18. 已回復的虛擬主機管理員程序
17.9. Displaying Virtual Machine Details
- 在虛擬主機管理主視窗,反白您欲瀏覽的虛擬主機。
圖形 17.19. 選取欲顯示的虛擬主機
- 在虛擬主機管理員 編修 選單,選取 主機詳細資料(或點選虛擬主機管理員主視窗下方的 詳細資料 鈕)。
圖形 17.20. 顯示虛擬主機詳細資料選單
顯示虛擬主機詳細資料總覽視窗。這個視窗總結您指定的網域之 CPU 與記憶體使用率。圖形 17.21. 顯示虛擬主機詳細資料總覽
- 在虛擬主機詳細資料視窗,點選 Hardware 欄標。顯示虛擬主機詳細資料硬體視窗。
圖形 17.22. 顯示虛擬主機詳細資料硬體
- 在 硬體 欄標,點選 處理器 來瀏覽或更改目前處理器記憶體設定。
圖形 17.23. 顯示處理器設定
- 在 硬體 欄標,點選 記憶體 來瀏覽或更改目前 RAM 記憶體設定。
圖形 17.24. 顯示記憶體設定
- 在 硬體 欄標,點選 磁碟 來瀏覽或更改目前硬碟設定。
圖形 17.25. 顯示磁碟設定
- 在 硬體 欄標,點選 網路 來瀏覽或更改目前網路設定。
圖形 17.26. 顯示網路設定
17.10. Configuring Status Monitoring
- 在 修改 選單,點選 偏好。
圖形 17.27. 修改虛擬主機偏好
顯示虛擬主機管理員偏好視窗。 - 在狀態監測區選取方塊,指定您欲系統更新的時間(已秒為單位)。
圖形 17.28. Configuring Status Monitoring
- 在主控區,指定開啟主控台的方式與指定輸入裝置。
17.11. 顯示網域 ID
- 在 瀏覽 選單,選取 網域 ID 確認方塊。
圖形 17.29. 顯示網域—ID
- The Virtual Machine Manager lists the Domain ID's for all domains on your system.
圖形 17.30. 顯示網域—ID
17.12. 顯示虛擬主機狀態
- 在 瀏覽 選單,點選 狀態 確認方塊。
圖形 17.31. 顯示虛擬主機狀態
- 虛擬主機管理院將系統上所有虛擬主機的狀態列出。
圖形 17.32. 顯示虛擬主機狀態
17.13. 顯示虛擬 CPU
- 在 瀏覽 選單,選取 虛擬 CPU 確認方塊。
圖形 17.33. 顯示虛擬 CPU
- 虛擬主機管理員將系統上所有虛擬主機的虛擬 CPU 列出。
圖形 17.34. 顯示虛擬 CPU
17.14. 顯示 CPU 使用率
- 在 瀏覽 選單,選取 CPU 使用率 確認方塊。
圖形 17.35. 顯示 CPU 使用率
- 虛擬主機管理員將系統上所有虛擬主機的 CPU 使用比率列出。
圖形 17.36. 顯示 CPU 使用率
17.15. 顯示記憶體使用率
- 在 瀏覽 選單,選取 記憶體使用率 確認方塊。
圖形 17.37. 顯示記憶體使用率
- 虛擬主機管理員將系統上左有虛擬主機的記憶體(以 MB 為單位)使用比率列出。
圖形 17.38. 顯示記憶體使用率
17.16. Managing a Virtual Network
- From the Edit menu, select Host Details.
圖形 17.39. Selecting Host Details
- This will open the Host Details menu. Click the Virtual Networks tab.
圖形 17.40. Virtual Network Configuration
- All available virtual networks are listed on the left-hand box of the menu. You can edit the configuration of a virtual network by selecting it from this box and editing as you see fit.
17.17. Creating a Virtual Network
- Open the Host Details menu (refer to 節 17.16, “Managing a Virtual Network”) and click the Add button.
圖形 17.41. Virtual Network Configuration
This will open the Create a new virtual network menu. Click Forward to continue.圖形 17.42. Creating a new virtual network
- Enter an appropriate name for your virtual network and click Forward.
圖形 17.43. Naming your virtual network
- Enter an IPv4 address space for your virtual network and click Forward.
圖形 17.44. Choosing an IPv4 address space
- Define the DHCP range for your virtual network by specifying a Start and End range of IP addresses. Click Forward to continue.
圖形 17.45. Selecting the DHCP range
- Select how the virtual network should connect to the physical network.
圖形 17.46. Connecting to physical network
If you select Forwarding to physical network, choose whether the Destination should be NAT to any physical device or NAT to physical device eth0.Click Forward to continue. - You are now ready to create the network. Check the configuration of your network and click Finish.
圖形 17.47. Ready to create network
- The new virtual network is now available in the Virtual Network tab of the Host Details menu.
圖形 17.48. New virtual network is now available
章 18. Red Hat 虛擬化故障排除
18.1. 登錄檔概述與位置
- Red Hat 虛擬化主設定目錄為
/etc/xen/
。這個目錄包括xend
網域與其他虛擬主機設定檔案。網路 script 檔案也位於此處(在/scripts
子目錄中)。 - 所有您會需要使用故障排除的實際登錄檔案都位於
/var/log/xen
目錄。
- 同時,所有虛擬主機磁碟目錄檔案都位於預設目錄
/var/lib/xen
。 /proc
檔案系統的 Red Hat 虛擬化資訊位於/proc/xen/
目錄。
18.2. 登錄檔性質
xend
daemon 與 qemu-dm
程序兩個功能,這兩個工具寫入多個登錄檔於 /var/log/xen/
目錄:
xend.log
為登錄檔,包含了所有由xend
daemon 所匯集的資料,不論事普通系統作業或是作業初始行為。所有的虛擬主機作業(如建立、關機、銷毀等)會在此顯示。如果在作業時發生問題,xend.log
通常為您第一個應該先查詢的地方。這個登錄檔包含了詳細資料項目與錯誤訊息的狀況。xend-debug.log
為包含所有從xend
與虛擬化子系統錯誤(框架緩衝器、Python scripts 等)的事件紀錄的登錄檔案。
xen-hotplug-log
為包含所有從 hotplug 事件的登錄檔。如果裝置或網路 script 沒有在線上,會於此顯示。qemu-dm.[PID].log
是由qemu-dm
程序為每一個完全虛擬化客座端所建立的登錄檔。當您使用登錄檔時,您必須擷取已知的qemu-dm
程序 PID,使用ps
指令來測試程序參數以及隔離在虛擬主機上的qemu-dm
程序。請注意,您必須使用真正的 PIDqemu-dm
程序來替代 [PID] 符號。
/.virt-manager
目錄中,virt-manager.log
檔案內所產生的資料。請注意,每次您啟動虛擬主機管理程式時,程式會覆蓋既有的登錄檔內容。在系統錯誤重新啟動虛擬主機管理程式之前,請確定已將 virt-manager.log
檔案備份。
18.3. 重要目錄位置
- 虛擬主機映像檔位於
/var/lib/xen/images
目錄中。
- 當您重新啟動
xend
daemon 時,它會更新位於/var/lib/xen/xend-db
目錄的xend-database
。
- 虛擬主機傾印(在您執行
xm dump-core
指令)位於/var/lib/xen/dumps
目錄中。
/etc/xen
目錄包含您用來管理系統資源的設定檔。xend
daemon 的設定檔稱為xend-config.sxp
,您可以使用這個檔案來實施整個系統的更改與設定網路通報。
proc
指令是另一項讓您能夠取得系統資訊的資源。過程項目位於/proc/xen
目錄中。
/proc/xen/capabilities
/proc/xen/balloon
/proc/xen/xenbus/
18.4. 故障排除工具
xentop
xm dmesg
xm log
vmstat
iostat
lsof
XenOprofile
systemTap
crash
sysrq
sysrq t
sysrq w
ifconfig
tcpdump
brctl
brctl
為網路工具,用來檢查與設定在虛擬化 linux 核心中的乙太網橋接設定。您必須能夠以 root 身份登入,才能執行下列範例指令:
# brctl show bridge-name bridge-id STP enabled interfaces ----------------------------------------------------------------------------- xenbr0 8000.feffffff no vif13.0 xenbr1 8000.ffffefff yes pddummy0 xenbr2 8000.ffffffef no vif0.0 # brctl showmacs xenbr0 port-no mac-addr local? ageing timer 1 fe:ff:ff:ff:ff: yes 0.00 2 fe:ff:ff:fe:ff: yes 0.00 # brctl showstp xenbr0 xenbr0 bridge-id 8000.fefffffffff designated-root 8000.fefffffffff root-port 0 path-cost 0 max-age 20.00 bridge-max-age 20.00 hello-time 2.00 bridge-hello-time 2.00 forward-delay 0.00 bridge-forward-delay 0.00 ageing-time 300.01 hello-timer 1.43 tcn-timer 0.00 topology-change-timer 0.00 gc-timer 0.02
18.5. 使用紀錄來排除故障
xend.log
file contains the same basic information as when you run the xm log
command. It resides in the /var/log/
directory. Here is an example log entry for when you create a domain running a kernel:
[2006-12-27 02:23:02 xend] ERROR (SrvBase: 163) op=create: Error creating domain: (0, 'Error') Traceback (most recent call list) File "/usr/lib/python2.4/site-packages/xen/xend/server/SrvBase.py" line 107 in_perform val = op_method (op,req) File "/usr/lib/python2.4/site-packages/xen/xend/server/SrvDomainDir.py line 71 in op_create raise XendError ("Error creating domain: " + str(ex)) XendError: Error creating domain: (0, 'Error')
xend-debug.log
適用於系統管理員,因為它包含比 xend.log
更多的詳細資訊。下列為與建立核心網域時所會遇到的相同錯誤資料:
ERROR: Will only load images built for Xen v3.0 ERROR: Actually saw: GUEST_OS=netbsd, GUEST_VER=2.0, XEN_VER=2.0; LOADER=generic, BSD_SYMTAB' ERROR: Error constructing guest OS
18.6. 序列主控台的故障排除
grub.conf
檔案來啟動 com1 /dev/ttyS0
上的 38400-bps 序列主控台:
title Red Hat Enterprise Linix (2.6.18-8.2080_RHEL5xen0) root (hd0,2) kernel /xen.gz-2.6.18-8.el5 com1=38400,8n1 module /vmlinuz-2.618-8.el5xen ro root=LABEL=/rhgb quiet console=xvc console=tty xencons=xvc module /initrd-2.6.18-8.el5xen.img
sync_console
can help determine a problem that causes hangs with asynchronous hypervisor console output, and the "pnpacpi=off"
works around a problem that breaks input on the serial console. The parameters "console=ttyS0"
and "console=tty"
means that kernel errors get logged with on both the normal VGA console and on the serial console. Then you can install and set up ttywatch
to capture the data on a remote host connected by a standard null-modem cable. For example, on the remote host you could type:
ttywatch --name myhost --port /dev/ttyS0
/dev/ttyS0
輸入到檔案 /var/log/ttywatch/myhost.log
中。
18.7. 半虛擬化客座端主控台存取
xm console [domain name or number]
domain100
代表執行名稱或號碼。您同時也可以選擇虛擬主機管理程式來顯示虛擬文字主控台。在虛擬主機詳細資料視窗,從 瀏覽 選單選取 序列主控台。
18.8. 完整虛擬化客座端主控台存取
grub.conf
file, and include the 'console =ttyS0 console=tty0'
parameter. This ensures that the kernel messages are sent to the virtual serial console (and the normal graphical console). If you plan to use the virtual serial console in a full virtualized guest, you must edit the configuration file in the /etc/xen/
directory. On the host domain, you can then access the text console by typing:
xm console
18.9. 執行 Lun 持續性
udev
來執行 lun 持續性。在您的系統上執行 lun 持續性前,請確定您取得正確的 UUID。在您取得之後,您可以透過編輯位於 /etc
目錄中的 scsi_id
檔案來設定 lun 持續性。
# options=-b
# options=-g
# scsi_id -g -s /block/sdc
[root@devices] # scsi_id -g -s /block/sdc *3600a0b80001327510000015427b625e*
/etc/udev/rules.d
目錄中的 20-names.rules
檔案。您應該依照下列格式建立裝置命名規則:
# KERNEL="sd*", BUS="scsi", PROGRAM="sbin/scsi_id", RESULT="UUID", NAME="devicename"
KERNEL="sd*", BUS="scsi", PROGRAM="sbin/scsi_id", RESULT="3600a0b80001327510000015427b625e ", NAME="mydevicename"
/dev/sd*
的裝置來檢視 UUID。當它找到符合的裝置時,會建立稱為 /dev/devicename
的裝置節點。以這個範例來說,這個裝置節點為 /dev/mydevice
。最後您需要附加位於 /etc
目錄中的 rc.local
檔案至這個路徑:
/sbin/start_udev
/etc/
目錄中的 multipath.conf
檔案來定義四個裝置別名:
multipath { wwid 3600a0b80001327510000015427b625e alias oramp1 } multipath { wwid 3600a0b80001327510000015427b6 alias oramp2 } multipath { wwid 3600a0b80001327510000015427b625e alias oramp3 } multipath { wwid 3600a0b80001327510000015427b625e alias oramp4 }
/dev/mpath/oramp1
、/dev/mpath/oramp2
、/dev/mpath/oramp3
與 dev/mpath/oramp4
。這些裝置將放至於 /dev/mpath
目錄中。這些 lun 名稱將會持需於重新開機,因為它會建立別名於 lun 的 wwid。
18.10. SELinux 考量
# semanage fcontext -a -t xen_image _t -f -b /dev/sda2 # restorecon /dev/sda2
xend_disable_trans
在充新啟動 daemon 後將 xend
置於自由模式。最好的是將單一 daemon 的保護程式關閉而非整個系統。建議不要將通用的 xen_image_t
更改標籤。
18.11. 在客座端磁碟映像檔上存取資料
yum install kpartx kpartx -av /dev/xen/guest1 add map guest1p1 : 0 208782 linear /dev/xen/guest1 63 add map guest1p2: 0 16563015 linear /dev/xen/guest1 208845
# kpartx -a /dev/xen/guest1 #vgscan Reading all physical volumes . This may take a while... Found volume group "VolGroup00" using metadata type 1vm2 # vgchange -ay VolGroup00 2 logical volume(s) in volume group VolGroup00 now active. # lvs LV VG Attr Lsize Origin Snap% Move Log Copy% LogVol00 VolGroup00 -wi-a- 5.06G LogVol01 VolGroup00 -wi-a- 800.00M # mount /dev/VolGroup00/LogVol00 /mnt/ .... #umount /mnt/ #vgchange -an VolGroup00 #kpartx -d /dev/xen/guest1
vgchange -an
將邏輯空間停止,並在結束後移除 kpartx-d
的分割區,與刪除 losetup -d
的迴路裝置。
18.12. 通常故障排除狀況
xend
服務時沒有反應。您可以輸入 xm list1
並接收下列:
Error: Error connecting to xend: Connection refused. Is xend running?
xend start
但有更多錯誤出現:
Error: Could not obtain handle on privileged command interfaces (2 = No such file or directory) Traceback (most recent call last:) File "/usr/sbin/xend/", line 33 in ? from xen.xend.server. import SrvDaemon File "/usr/lib/python2.4/site-packages/xen/xend/server/SrvDaemon.py" , line 26 in ? from xen.xend import XendDomain File "/usr//lib/python2.4/site-packages/xen/xend/XendDomain.py" , line 33, in ? from xen.xend import XendDomainInfo File "/usr/lib/python2.4/site-packages/xen/xend/image.py" , line37, in ? import images File "/usr/lib/python2.4/site-packages/xen/xend/image.py" , line30, in ? xc = xen.lowlevel.xc.xc () RuntimeError: (2, 'No such file or directory' )
xen-hypervisor
核心的核心。欲修改這個問題,您必須在開機時(或將 xen-hypervisor
核心預設於您的 grub.conf
檔案中)選取 xen-hypervisor
核心。
18.13. 迴路裝置錯誤
/etc/modprobe.conf
檔案。在您編修 modprobe.conf
檔案時,您必須包括下列指令列:
options loop max_loop=64
phy: block device
或 tap:aio
指令。欲套用迴路裝置支援客座端於全虛擬系統,使用 phy: device
或 file: file
指令。
18.14. 客座端建立錯誤
"Invalid argument"
error message. This usually means that the kernel image you are trying to boot is incompatible with the hypervisor. An example of this would be if you were attempting to run a non-PAE FC5 kernel on a PAE only FC6 hypervisor.
grub.conf
預設核心轉回裸機核心而非虛擬化核心。
/etc/sysconfig/kernel/
目錄中的預設核心 RPM。您必須確認在 gb.conf
檔案中 kernel-xen
參數為預設選項。
18.15. 序列主控台錯誤
grub.conf
並更改 com 埠參數:
serial --unit=1 --speed=115200
title RHEL5 i386 Xen (2.6.18-1.2910.el5xen) root (hd0, 8) kernel /boot/xen.gz-2.6.18-1.2910.el5 com2=115200,8n1 module /boot/vmlinuz-2.6.18-1.2910.el5xen to root=LABEL=RHEL5_i386 console=tty console=ttyS1115200 module /boot/initrd-2.8.6.18-12910.el5xen.img title RHEL5 i386 xen (2.6.18.-1.2910.el5xen root (hd0, 8) kernel /boot/xen.gz-2.6.18-1.2910.el5 com2=115200 console=com2l module /boot/vmlinuz2.6.18-1.2910.el5xen to root=LABEL=RHEL5_i386 console=xvc xencons=xvc module /boot/ititrd-2.6.18-1.2910.el5xen.img
grub.conf
變更應該能讓序列主控台恢復正常運作。您應該可以使用任何數字在 ttyS
上,如 ttyS0
。
18.16. 網路橋接錯誤
/etc/sysconfig/network-scripts
. You should use a process to setup multiple Xen bridges. This is an example config file for a second NIC called 'eth1'
:
#/etc/sysconfig/network-scripts/fcfg-eth1 DEVICE=eth1 BOOTPROTO=static ONBOOT=yes USERCTL=no IPV6INIT=no PEERDNS=yes TYPE=Ethernet NETMASK=255.255.255.0 IPADDR=10.1.1.1 GATEWAY=10.1.1.254 ARP=yes
/etc/xen/scripts/network-bridge
複製到 /etc/xen/scripts/network-bridge.xen
。
/etc/xen/xend-config.sxp
and add a line to your new network bridge script (this example uses "network-virtualization-multi-bridge"
).
xend-config.sxp
檔案中。新的指令列應該會反應新的 script:
network-script network-xen-multi-bridge
network-script network-bridge
xenbr0
與 xenbr1
)然後將他們對應附於 eth1
與 eth0
。
# !/bin/sh # network-xen-multi-bridge # Exit if anything goes wrong set -e # First arg is operation. OP=$1 shift script=/etc/xen/scripts/network-bridge.xen case ${OP} in start) $script start vifnum=1 bridge=xenbr1 netdev=eth1 $script start vifnum=0 bridge=xenbr0 netdev=eth0 ;; stop) $script stop vifnum=1 bridge=xenbr1 netdev=eth1 $script stop vifnum=0 bridge=xenbr0 netdev=eth0 ;; status) $script status vifnum=1 bridge=xenbr1 netdev=eth1 $script status vifnum=0 bridge=xenbr0 netdev=eth0 ;; *) echo 'Unknown command: ' ${OP} echo 'Valid commands are: start, stop, status' exit 1 esac
18.17. 筆記型電腦設定
ifcfg-dummy0
並位於 /etc/sysconfig/network-scripts/
目錄中:
DEVICE =dummy0 BOOTPROTO=none ONBOOT=yes USERCTL=no IPV6INIT=no PEERDNS=yes TYPE=Ethernet NETMASK=255.255.255.0 IPADDR=10.1.1.1 ARP=yes
xenbr0
併到 dummy0
讓網路連接,即使從實體網路斷開。
xend-config.sxp
file. You must locate the ( network-script 'network-bridge' bridge=xenbr0
) section and add include this in the end of the line:
netdev=dummy0
/etc/sysconfig/
directory to reflect the example below:
NETWORKING=yes HOSTNAME=localhost.localdomain GATEWAY=10.1.1.1 IPADDR=10.1.1.10 NETMASK=255.255.255.0
/etc/rc3.d
目錄中的 S99XenLaptopNAT
檔案如下列範例:
#!/bin/bash # # XenLaptopNAT Startup script for Xen on Laptops # # chkconfig: - 99 01 # description: Start NAT for Xen Laptops # # PATH=/usr/bin:/sbin:/bin:/usr/sbin # export PATH GATEWAYDEV=`ip route | grep default | awk {'print $5'}` iptables -F case "$1" in start) if test -z "$GATEWAYDEV"; then echo "No gateway device found" else echo "Masquerading using $GATEWAYDEV" /sbin/iptables -t nat -A POSTROUTING -o $GATEWAYDEV -j MASQUERADE fi echo "Enabling IP forwarding" echo 1 > /proc/sys/net/ipv4/ip_forward echo "IP forwarding set to `cat /proc/sys/net/ipv4/ip_forward`" echo "done." ;; *) echo "Usage: $0 {start|restart|status}" ;; esac
/etc/rc3.d/S99XenLaptopNAT
。
modprobe.conf
檔案時,您必須加入下列命令列
alias dummy0 dummy options dummy numdummies=1
18.18. Starting Domains Automatically During System Boot
/etc/xen/auto
的符號連結。這個檔案會指向需要自動啟始的客座端設定檔。啟動的程序是連續的,即數字較高的客座端需要較長的時間來完成啟動。這個範例告訴您如何使用符號連結於客座端 rhel5vm01
:
[root@python xen]# cd /etc/xen [root@python xen]# cd auto [root@python auto]# ls [root@python auto]# ln -s ../rhel5vm01 . [root@python auto]# ls -l lrwxrwxrwx 1 root root 14 Dec 14 10:02 rhel5vm01 -> ../rhel5vm01 [root@python auto]#
18.19. 修改 domain0
grub.conf
configuration file, that resides in the /etc
directory. Because of the large number of domains to manage, many system administrators prefer to use the 'cut and paste' method when editing grub.conf
. If you do this, make sure that you include all five lines in the Virtualization entry (or this will create system errors). If you require Xen hypervisor specific values, you must add them to the 'xen' line. This example represents a correct grub.conf
Virtualization entry:
# boot=/dev/sda/ default=0 timeout=15 #splashimage=(hd0, 0)/grub/splash.xpm.gz hiddenmenu serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 terminal --timeout=10 serial console title Red Hat Enterprise Linux Server (2.6.17-1.2519.4.21. el5xen) root (hd0, 0) kernel /xen.gz-2.6.17-1.2519.4.21.el5 com1=115200,8n1 module /vmlinuz-2.6.17-1.2519.4.21el5xen ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.17-1.2519.4.21.el5xen.img
'dom0_mem=256M'
. This example represents the respective grub.conf
xen entry:
# boot=/dev/sda default=0 timeout=15 #splashimage=(hd0,0)/grubs/splash.xpm.gz hiddenmenu serial --unit=0 --speed =115200 --word=8 --parity=no --stop=1 terminal --timeout=10 serial console title Red Hat Enterprise Linux Server (2.6.17-1.2519.4.21. el5xen) root (hd0,0) kernel /xen.gz-2.6.17-1.2519.4.21.el5 com1=115200,8n1 dom0_mem=256MB module /vmlinuz-2.6.17-1.2519.4.21.el5xen ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.17-1.2519.4.21.el5xen.img
18.20. 客座端設定檔案
name = "rhel5vm01" memory = "2048" disk = ['tap:aio:/xen/images/rhel5vm01.dsk,xvda,w',] vif = ["type=ieomu, mac=00:16:3e:09:f0:12 bridge=xenbr0', "type=ieomu, mac=00:16:3e:09:f0:13 ] vnc = 1 vncunused = 1 uuid = "302bd9ce-4f60-fc67-9e40-7a77d9b4e1ed" bootloader = "/usr/bin/pygrub" vcpus=2 on_reboot = "restart" on_crash = "restart"
serial="pty"
is the default for the configuration file. This configuration file example is for a fully-virtualized guest:
name = "rhel5u5-86_64" builder = "hvm" memory = 500 disk = ['file:/xen/images/rhel5u5-x86_64.dsk.hda,w'] vif = [ 'type=ioemu, mac=00:16:3e:09:f0:12, bridge=xenbr0', 'type=ieomu, mac=00:16:3e:09:f0:13, bridge=xenbr1'] uuid = "b10372f9-91d7-ao5f-12ff-372100c99af5' device_model = "/usr/lib64/xen/bin/qemu-dm" kernel = "/usr/lib/xen/boot/hvmloader/" vnc = 1 vncunused = 1 apic = 1 acpi = 1 pae = 1 vcpus =1 serial ="pty" # enable serial console on_boot = 'restart'
18.21. 複製客座端設定檔案
uuidgen(1)
command). Then for the vif
entries you must define a unique MAC address for each guest (if you are copying a guest configuration from an existing guest, you can create a script to handle it). For the xen bridge information, if you move an existing guest configuration file to a new host, you must update the xenbr
entry to match your local networking configuration. For the Device entries, you must modify the entries in the 'disk='
section to point to the correct guest image.
/etc/sysconfig/network
file to match the new guest's hostname.
/etc/sysconfig/network-scripts/ifcfg-eth0
檔案的 HWADDR 位置來對應從 ifconfig eth0
檔案的輸出,並且如果您使用動態 IP 位置,您必須修改 IPADDR 項目。
18.22. 建立用來產生 MAC 位置的 Script
#! /usr/bin/python # macgen.py script generates a MAC address for Xen guests # import random mac = [ 0x00, 0x16, 0x3e, random.randint(0x00, 0x7f), random.randint(0x00, 0xff), random.randint(0x00, 0xff) ] print ':'.join(map(lambda x: "%02x" % x, mac)) Generates e.g.: 00:16:3e:66:f5:77 to stdout
18.23. 設定虛擬主機即時轉移
xm migrate
command). Live migration can be done from the same command. However there are some additional modifications that you must do to the xend-config
configuration file. This example identifies the entries that you must modify to ensure a successful migration:
(xend-relocation-server yes)
- The default for this parameter is 'no', which keeps the relocation/migration server deactivated (unless on a trusted network) and the domain virtual memory is exchanged in raw form without encryption.
(xend-relocation-port 8002)
- 這個參數設定
xend
用來移動的埠。如果數值正確,請確定移除在這之前的註釋。 (xend-relocation-address )
- 您啟動
xend-relocation-server
後,這個參數為接收重定位槽連接的位置。在接收時,會拒絕移動至特定介面。 (xend-relocation-hosts-allow )
- This parameter controls the host that communicates with the relocation port. If the value is empty, then all incoming connections are allowed. You must change this to a space-separated sequences of regular expressions (such as
xend-relocation-hosts-allow- '^localhost\\.localdomain$'
). A host with a fully qualified domain name or IP address that matches these expressions are accepted.
18.24. 解釋錯誤訊息
failed domain creation due to memory shortage, unable to balloon domain0
xend.log
來找出這個錯誤:
[2006-12-21] 20:33:31 xend 3198] DEBUG (balloon:133) Balloon: 558432 Kib free; 0 to scrub; need 1048576; retries: 20 [2006-12-21] 20:33:31 xend. XendDomainInfo 3198] ERROR (XendDomainInfo: 202 Domain construction failed
xm list Domain0
command. If domain0 is not ballooned down, you can use the command "xm mem-set Domain-0 NewMemSize"
to check memory.
wrong kernel image: non-PAE kernel on a PAE
[root@smith]# xm create -c va base Using config file "va-base" Error: (22, 'invalid argument') [2006-12-14 14:55:46 xend.XendDomainInfo 3874] ERRORs (XendDomainInfo:202) Domain construction failed Traceback (most recent call last) File "/usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 195 in create vm.initDomain() File " /usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 1363 in initDomain raise VmError(str(exn)) VmError: (22, 'Invalid argument') [2006-12-14 14:55:46 xend.XendDomainInfo 3874] DEBUG (XenDomainInfo: 1449] XendDlomainInfo.destroy: domin=1 [2006-12-14 14:55:46 xend.XendDomainInfo 3874] DEBUG (XenDomainInfo: 1457] XendDlomainInfo.destroy:Domain(1)
Unable to open a connection to the Xen hypervisor or daemon
/etc/hosts
設定檔案中沒有本地主機項目時,這個錯誤便會發生。如果本地主機項目為啟動,請檢查該檔案。下列為一個不正確的本地主機項目之例子:
# Do not remove the following line, or various programs # that require network functionality will fail. localhost.localdomain localhost
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost localhost.localdomain. localhost
xen-xend.log file
中):
Bridge xenbr1 does not exist!
[root@trumble virt]# xm create r5b2-mySQL01 Using config file " r5b2-mySQL01" Going to boot Red Hat Enterprise Linux Server (2.6.18.-1.2747 .el5xen) kernel: /vmlinuz-2.6.18-12747.el5xen initrd: /initrd-2.6.18-1.2747.el5xen.img Error: Device 0 (vif) could not be connected. Hotplug scripts not working.
xend.log
會顯示下列錯誤訊息:
[2006-11-14 15:07:08 xend 3875] DEBUG (DevController:143) Waiting for devices vif [2006-11-14 15:07:08 xend 3875] DEBUG (DevController:149) Waiting for 0 [2006-11-14 15:07:08 xend 3875] DEBUG (DevController:464) hotplugStatusCallback /local/domain/0/backend/vif/2/0/hotplug-status [2006-11-14 15:08:09 xend.XendDomainInfo 3875] DEBUG (XendDomainInfo:1449) XendDomainInfo.destroy: domid=2 [2006-11-14 15:08:09 xend.XendDomainInfo 3875] DEBUG (XendDomainInfo:1457) XendDomainInfo.destroyDomain(2) [2006-11-14 15:07:08 xend 3875] DEBUG (DevController:464) hotplugStatusCallback /local/domain/0/backend/vif/2/0/hotplug-status
vif
項目。當您找到設定檔的 vif
項目,請將 xenbr0
視為預設橋接,確保正確項目類似於下列:
# vif = ['mac=00:16:3e:49:1d:11, bridge=xenbr0',]
[root@python xen]# xm shutdown win2k3xen12 [root@python xen]# xm create win2k3xen12 Using config file "win2k3xen12". /usr/lib64/python2.4/site-packages/xenxm/opts.py:520: Deprecation Warning: Non ASCII character '\xc0' in file win2k3xen12 on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details execfile (defconfig, globs, locs,) Error: invalid syntax 9win2k3xen12, line1)
18.25. 線上錯誤排除資源
- Red Hat 虛擬化中心
http://www.openvirtualization.com
- Red Hat Enterprise Linux 5 Beta 2 文件
http://www.redhat.com/docs/manuals/enterprise/RHEL-5-manual/index.html
- Libvirt API
http://www.libvirt.org
- virt 管理程式企劃主頁
http://virt-manager.et.redhat.com
- Xen 社群中心
http://www.xensource.com/xen/xen/
- 虛擬化技術概述
http://virt.kernelnewbies.org
- 新興技術企劃
http://et.redhat.com
章 19. 附加的資源
19.1. 有幫助的網頁
- http://www.cl.cam.ac.uk/research/srg/netos/xen/ — Xen™ 的半虛擬化主機管理員的工程網站(Red Hat Virtualization 就是由這裡衍生)。這個網站會維護上游的 Xen 專案 binary 與原始程式碼。並且它也同時含有資訊、架構的概觀、文件、以及與 Xen 還有和它相聯的技術上有相關的連結。
- http://www.libvirt.org/ — 這是與一個主機 OS 的虛擬化架構互相影響的
libvirt
虛擬化 API 的正式網站。 - http://virt-manager.et.redhat.com/ — 這是 Virtual Machine Manager(virt-manager),一個管理虛擬主機的圖形化應用程式的工程網站。
19.2. 已安裝的文件
/usr/share/doc/xen-<version-number>/
—. This directory contains a wealth of information about the Xen para-virtualization hypervisor and associated management tools, including a look at various example configurations, hardware-specific information, and the current Xen upstream user documentation.man virsh
and/usr/share/doc/libvirt-<version-number>
— Contains subcommands and options for thevirsh
virtual machine management utility as well as comprehensive information about thelibvirt
virtualization library API./usr/share/doc/gnome-applet-vm-<version-number>
— Documentation for the GNOME graphical panel applet that monitors and manages locally-running virtual machines./usr/share/doc/libvirt-python-<version-number>
— Provides details on the Python bindings for thelibvirt
library. Thelibvirt-python
package allows python developers to create programs that interface with thelibvirt
virtualization management library./usr/share/doc/python-virtinst-<version-number>
— Provides documentation on thevirt-install
command that helps in starting installations of Fedora and Red Hat Enterprise Linux related distributions inside of virtual machines./usr/share/doc/virt-manager-<version-number>
— Provides documentation on the Virtual Machine Manager, which provides a graphical tool for administering virtual machines.
附錄 A. 實作練習 1
- 要查看您的中央處理器是否有 PAE 支援的話,請輸入:
grep pae /proc/cpuinfo
- 下列的輸出顯示了一個擁有 PAE 支援的中央處理器。假如指令沒有回傳任何東西的話,那就代表這個中央處理器沒有 PAE 支援。這裡所有的實作練習都需要一個含有 PAE 分機或者是 x86_64 還是 ia64 的 i386 中央處理器才能進行。
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx up est tm2
virt-install
來安裝 RHEL5 Beta 2 Xen 的半虛擬化客座端。
virt-install
來安裝一個 Red Hat Enterprise Linux 5 Beta 2 Xen 客座端。
- 如要安裝您的 Red Hat Enterprise Linux 5 Beta 2 Xen 客座端的話,請於指令提示中輸入:
virt-install
。 - 當被要求安裝一個完整的虛擬化客座端,請輸入:
否
。 - 輸入
rhel5b2-pv1
做為您的虛擬主機名稱。 - 輸入 500 做為您 RAM 的分配。
- 請輸入
/xen/rhel5b2-pv1.img
為您的磁碟(客座端映像檔)。 - 請輸入 6 做為您磁碟的容量(客座端映像檔)。
- 請輸入
是
來啟動圖形化支援。 - 請輸入
nfs:server:/path/to/rhel5b2
做為您的安裝位置。 - 安裝程序會啟動。之後請按照安裝的程序進行。
- 安裝完成之後,請輸入
/etc/xen/rhel5b2-pv1
,並且執行以下的更變:#vnc=1#vncunused=1sdl=1 - 請使用一個文字編輯器來更改
/etc/inittab
,並且將它附加至這個檔案:init5.#id:3:initdefault:id:5:initdefault:
virt-manager
來安裝 RHEL5 Beta 2 Xen 的半虛擬客座端。
virt-manager
來安裝一個 Red Hat Enterprise Linux 5 Beta 2 Xen 的半虛擬化客座端。
- 如要安裝您的 Red Hat Enterprise Linux 5 Beta 2 Xen 客座端的話,請在指令提示符號輸入:
virt-manager
。 - 在開啟連接的視窗上,請選擇本地 Xen 主機,並且按下 連接。
- Start Red Hat's Virtual Machine Manager application, and from the File menu, click on New.
- 點選 下一步
- 輸入
rhel5b2-pv2
做為您的系統名稱,並且點選 下一步。 - 選擇 半虛擬化 並且點選 下一步。
- 輸入
nfs:server:/path/to/rhel5b2
做為您的安裝媒體的 URL,並且點選 下一步。 - 選擇
Simple 檔案
,鍵入/xen/rhel5b2-pv2.img
做為您的檔案位置。選擇 6000 MB,並且點選 下一步。 - 選擇 500 做為您的 VM Startup 與 Maximum Memory,並且點選 下一步。
- 點選 結束。
- To determine if your CPU has Intel-VT or AMD-V support, type the following command:
egrep -e 'vmx|svm' /proc/cpuinfo
- 下列的輸出顯示的是一個支援 Intel-VT 的中央處理器:
.flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe constant_tsc pni monitor vmx est tm2 xtpr
假如指令沒有回傳任何東西,這就代表這個中央處理器不支援 Intel-VT 或是 AMD-V。 - 要斷定您的 CPU 是否擁有 Intel-VT 或 AMD-V 的支援,請輸入下列指令:
cat /sys/hypervisor/properties/capabilities
- The following output shows that Intel-VT support has been enabled in the BIOS. If the command returns nothing, then go into the BIOS Setup Utlility and look for a setting related to 'Virtualization', i.e. 'Intel(R) Virtualization Technology' under 'CPU' section on a IBM T60p. Enable and save the setting and do a power off to take effect.
xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p
virt-install
來安裝一個 Red Hat Enterprise Linux 5 Beta 2 Xen 的完整虛擬化客座端。
- 如要安裝您的 Red Hat Enterprise Linux 5 Beta 2 Xen 客座端的話,請於指令提示中輸入:
virt-install
。 - 當提示符安裝一個完整的虛擬化客座端時,請輸入
是
。 - 輸入
rhel5b2-pv2
為您的虛擬主機名稱。 - 輸入 500 為您的記憶體分配。
- 輸入
/xen/rhel5b2-fv1.img
為您的磁碟(客座端映像檔)。 - 請輸入 6 做為您磁碟的容量(客座端映像檔)。
- 輸入
是
來啟動圖形化支援。 - 輸入
/dev/cdrom
做為虛擬 CD 映像檔。 - The VNC viewer appears within the installation window. If there is an error message that says “main: Unable to connect to host: Connection refused (111)”, then type the following command to proceed:
vncviewer localhost:5900
. VNC port 5900 refers to the first Xen guest that is running on VNC. If it doesn't work, you might need to use 5901, 5902, etc.
virt-manager
來安裝一個 Red Hat Enterprise Linux 5 Beta 2 Xen 的完整虛擬化客座端:
- 如要安裝您的 Red Hat Enterprise Linux 5 Beta 2 Xen 客座端的話,請在指令提示符號輸入:
virt-manager
。 - 在 開啟連接 視窗上,請選擇本地 Xen 主機,並且點選 連接。
- Start Red Hat's Virtual Machine Monitor application, and from the File menu, click on New.
- 點選 下一步
- 輸入
rhel5b2-fv2
為您的系統名稱,並且點選 下一步。 - 選擇完整虛擬化,並且點選 下一步。
- 指定 CD-ROM 或是 DVD,並且輸入路徑來安裝媒體。假如您要由一個映像檔安裝的話,請指定 ISO 映像檔的位置。接著點選 下一步.。
- 選擇簡單的檔案,請輸入
/xen/rhel5b2-fv2.img
做為您的 檔案位置。指定 6000 MB 並且點選 下一步。 - 選擇 500 做為您的 VM Startup 與 Maximum Memory,並且點選 下一步。
- 點選 結束。
- 虛擬主機主控台視窗會出現。
virt-manager
來安裝 RHEL3 Xen 的完整虛擬化客座端。
virt-manager
來安裝一個 Red Hat Enterprise Linux 3 Xen 的客座端:
- 用在練習 6 的相同指示也能應用在這裡。
virt-manager
來安裝 RHEL4 Xen 的完整虛擬化客座端
virt-manager
來安裝一個 Red Hat Enterprise Linux 4 Xen 的客座端:
- 用在練習 6 的相同指示也能應用在這裡。
virt-manager
來安裝 Windows XP Xen 的完整虛擬化客座端。
virt-manager
來安裝 Windows XP Xen 的完整虛擬化客座端。
- 如要安裝您的 Red Hat Enterprise Linux 5 至您的 Windows XP 主機上,請在指令提示符號上輸入:
virt-manager
。 - 在 開啟連接 視窗上,選擇本地 Xen 主機,並且點選 連接。
- Start Red Hat's Virtual Machine Manager application, and from the File menu click on New.
- 點選 下一步
- 輸入
winxp
做為您的系統名稱,並且點選 下一步。 - 選擇完整虛擬化,並且點選 下一步。
- 指定 CD-ROM 或 DVD,並且輸入安裝媒體的路徑。假如您要由一個 ISO 映像檔來安裝的話,請指定 ISO 映像檔的位置,並且點選 下一步。
- 選擇簡單的檔案,輸入
/xen/winxp.img
做為您的檔案位置。指定 6000 MB,並且點選 下一步。 - 選擇 1024 為您的 VM Startup 與 Maximum Memory,並且選擇 2 為 VCPU。點選 下一步 。
- 點選 結束。
- 虛擬主機主控台的視窗將會出現。請按照正常程序完成安裝。
- 選擇將
C:\
磁碟分割格式化為 FAT 檔案系統格式。Red Hat Enterprise Linux 5 並不包含 NTFS 核心模組。安裝或者是將檔案寫至 Xen 客座端映像檔可能不會像將磁碟分割格式化為 NTFS 檔案系統格式一樣的簡單直接。 - 在您第一次重新啟動系統之後,請編輯
winxp
的客座端映像檔:losetup /dev/loop0 /xen/winxp.imgkpartx -av /dev/loop0mount /dev/mapper/loop0p1 /mntcp -prv $WINDOWS/i386 /mnt/
。這能夠處理一個您之後在 Windows 的安裝之間可能會遇上的問題。 - 如要將 Xen 客座端重新啟動請輸入:
xm create -c winxp/
。 - 在虛擬主機管理的視窗中,選擇
winxp
Xen 客座端然後點選 開啟。 - 虛擬主機主控台的視窗會出現。請按照正常程序完成安裝。
- Whenever a 'Files Needed' dialog box appears, change the path
GLOBALROOT\DEVICE\CDROM0\I386
toC:\I386
. Depending on your installation, you may or may not see this problem. You may be prompted for missing files during the installation. Changing the path toC:\I386
should compensate for this problem. - 假如 Xen 客座端主控台凍結的話,點選
shutdown
,並且在/etc/xen/winxp:#vnc=1#vncunused=1sdl=1#vcpus=2
中執行下列的更變: - 重複第 14 步,並且按照正常的程序進行安裝。
附錄 B. 實作練習 2
host1
與 host2
。
xm
)啟動 UNIX 網域插槽管理伺服器並且與 xend 交流。為了要能使跨越主機的即時遷移生效,您必須設定它來支援即時遷移:
- 如要製作一份您的
xend-config.sxp
檔案的備份:cp -pr /etc/xen/xend-config.sxp /etc/xen/xend-config.sxp.default
- 編輯
/etc/xen/xend-config.sxp
並且執行下列的變更:#(xend-unix-server yes)(xend-relocation-server yes)(xend-relocation-port 8002)(xend-relocation-address '')(xend-relocation-hosts-allow '')#(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$')
- 重新啟動
xend:服務
與xend
的重新啟動。
- 編輯
/etc/exports
並且包含/xen *(rw,sync,no_root_squash)/
這個行列 - 儲存
/etc/exports
並且重新啟動 NFS 伺服器。請確認 NFS 伺服器是由default:service nfs startchkconfig nfs on
所開啟的。 - 當在
host1
上啟動了 NFS 伺服器之後,我們就能夠將它安裝在host2:mount host1:/xen /xen
上。 - 現在請啟動
host1
上的 Xen 客座端並且選擇fc6-pv1
(或者是練習 1 的fc6-pv2
)。xm create -c fc6-pv1
- 請由
http://www.gnump3d.org/
下載gnump3d-2.9.9.9.tar.bz2
tarball。將這個 tarball 拆包打開並且在gnump3d-2.9.9.9/
目錄中,編譯,並且安裝gnump3d application:tar xvjf gnump3d-2.9.9.9.tar.bz2cd gnump3d-2.9.9.9/make install
- Create a
/home/mp3
directory and copy TruthHappens.ogg from Red Hat's Truth Happens page tomkdir /home/mp3wget -c http://www.redhat.com/v/ogg/TruthHappens.ogg
- 當啟動串流伺服器時請輸入
command:gnump3d
- 請在兩台中的其中一台 Xen 主機上執行 Movie Player。假如還未安裝的話,請在執行 Movie Player 前安裝 totem 以及 iso-codecs rpms。點選 Application,接著 Sound & Video,最後 Movie Player。
- 請點選 Movie,接著 Open Location。輸入 http://guest:8888/TruthHappens.ogg。
- 請於兩台虛擬化主機中的其中一台上執行
TruthHappens.ogg
這個檔案。 - 請由
host1
至host2
執行即時遷移:xm migrate –live fc6-pv1 host2
- 請於這兩台 Xen 主機上開啟多重視窗終端機並且輸入下列指令:
watch -n1 xm list
- 請觀察即時遷移,並且注意遷移的完成需要花多久的時間。
gdm
starts up. Run VNC viewer and connect to the Xen guest. Play with the Xen guest when the live migration occurs. Attempt to pause/resume, and save/restore the Xen guest and observe what happens to the VNC viewer. If you connect to the VNC viewer via localhost:590x
, and do a live migration, you won't be able to connect to the VNC viewer again when it dies. This is a known bug.
附錄 C. 修訂紀錄
修訂記錄 | ||||
---|---|---|---|---|
修訂 2.0-11.400 | 2013-10-31 | Rüdiger Landmann | ||
| ||||
修訂 2.0-11 | 2012-07-18 | Anthony Towns | ||
| ||||
修訂 5.1.0-10 | Fri Aug 3 2007 | Michael Hideo Smith | ||
|