Red Hat Training
A Red Hat training course is available for Red Hat Enterprise Linux
附錄 B. 實作練習 2
即時遷移
目標:在兩台主機之間進行一個即時遷移的設定與執行。
先決條件:兩台安裝著含有虛擬化平台的 Red Hat Enterprise Linux 5.0 Beta 2 的工作站,以及一個 Fedora Core 6 Xen 客座端在其中一台工作站上。
在這項實作練習中,您需要在兩台主機之間設定遷移並且執行一項即時的遷移。
導言:在您開始之前
在這項實作練習中,您需要兩台虛擬化主機:一個 Xen 客座端以及一個分享的儲存器。您必須使用一條 UTP 纜線來將兩台虛擬化主機連結在一起。其中一台虛擬化主機會由 NFS 導出一個分享的儲存器。您必須要設定這兩台虛擬化主機才能讓它們成功的遷移。Xen 客座端處於分享儲存器上。在 Xen 客座端上,您應安裝一個串流伺服器。您必須要確認串流伺服器在 Xen 客座端上能在沒有中斷的狀態下執行,這樣的話兩台虛擬化主機之間的即時遷移才能完成。在實作練習 2 中,您將把這兩台虛擬化主機歸類為
host1
與 host2
。
練習序列 1:設定 xend(兩台 Xen 主機)
在這項實作練習程序中,您將設定 xend 並以一個 HTTP 伺服器和再定位伺服器來啟動。以預設值來說,xend daemon 並不會啟動 HTTP 伺服器。它會(為
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
的重新啟動。
序列 2:由 NFS 導出一個分享的儲存空間
在這項實作練習的程序當中,您需要設定 NFS 並且使用它來導出一個分享的儲存空間。
- 編輯
/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
序列 3:安裝 Xen 客座端的串流伺服器
在此項實作練習中,為了要能夠示範,您必須安裝一個串流伺服器 gnump3d。您之所以該選擇 gnump3d 是因為它支援 OGG vorbis 檔案並且它在安裝、設定、與更改上都很容易。
- 請由
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。
序列 4:執行即時遷移
- 請於兩台虛擬化主機中的其中一台上執行
TruthHappens.ogg
這個檔案。 - 請由
host1
至host2
執行即時遷移:xm migrate –live fc6-pv1 host2
- 請於這兩台 Xen 主機上開啟多重視窗終端機並且輸入下列指令:
watch -n1 xm list
- 請觀察即時遷移,並且注意遷移的完成需要花多久的時間。
挑戰:由 Xen 客座端之中來設定 VNC 伺服器
If time permits, from within the Xen guest, configure the VNC server to initiate when
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.