[[PageOutline]]
{{{
#!html
實作六:Eucalyptus 管理介面和 Euca2ools 操作
}}}
= 【前言】 =
* 使用的 OS 為 Debian etch (5.0.3) AMD64
* 桌面的 '''Web Broswer''' 為瀏覽器
* 桌面的 '''終端機''' 用來輸入課程中的指令
* 為了方便學員,可以使用 '''__複製__'''和'''__貼上__''' 繁瑣的指令 (請複製 "$" 之後的指令)
* 黑底白字部份為指令
* 第1個指令為 使用 '''vim''' 指令來編輯 hosts 這個文件
* 第2個指令的 '''sudo''' 為轉換成 root 管理者身份來編輯此文件 (因 hosts 文件的權限只有 root 能修改)
* 第3個指令的 '''gedit''' 給不習慣用 vim 的學員使用 (類似 windows 的 notepad)
{{{
$ vim /etc/hosts
$ sudo vim /etc/hosts
$ sudo gedit /etc/hosts
}}}
* 白底黑字為文件內容
{{{
#!sh
127.0.0.1 localhost
}}}
* 若是文件內容前面有數字則為行數 (方便學員可以快速找到文件編輯位置,下圖則為 /etc/hosts 文件的第1行)
{{{
#!sh
1 127.0.0.1 localhost
}}}
----
{{{
#!graphviz
digraph finite_state_machine {
rankdir=LR;
ranksep=0.3;
size="11,8";
node[shape=box,width=3.0];
"3.使用 Euca2ools 來操作 Eucalyptus" -> "4.使用 Euca2ools 上傳 Kernel / Ramdisk / FS Image";
"1.新增 Eucalyptus API 套件庫" -> "2.下載帳戶憑證";
}
}}}
----
= 【Step 1:安裝 Eucalyptus API】 =
* 到[http://open.eucalyptus.com/downloads 此網站]下載 Eucaluyptus API - Euca2ools (下載至家目錄)
* 將下載的套件新增至套件庫
{{{
$ cd
$ tar zxvf euca2ools-1.0-lenny-i386.tar.gz
$ cd euca2ools-1.0-lenny-i386
$ sudo su
$ echo deb file://${PWD} ./ >> /etc/apt/sources.list
}}}
* 使用 '''__aptitude install__'''指令安裝 euca2ools
{{{
$ sudo aptitude update
$ sudo aptitude install euca2ools
}}}
----
【Step 2:下載帳戶憑證】
* 使用你的帳戶登入到 Eucalyptus Web 並下載你的憑證 (要用 Euca2ools 控制 Eucalyptus 必須要讓 Eucalyptus 系統信任你,所以需要此憑證)
* 下載至你的家目錄
[[Image(down.png,width=800)]]
{{{
$ cd
$ mkdir euca
$ mv euca2-admin-x509.zip euca/
$ unzip euca2-admin-x509.zip
}}}
* 解開壓縮檔後,它有4個檔案,當中的 eucarc 是每次你要使用 Euca2ools 必須先 source 它 (他會幫設定好環境變數和認証Key)
{{{
$ source eucara
}}}
----
【Step 3:使用 Euca2ools 來操作 Eucalyptus】
* 使用 Euca2ools 提供的 '''__ecca-describe-availability-zones__''' 指令察看可用的資源
{{{
$ source eucarc
$ euca-describe-availability-zones verbose
}}}
* 使用 Euca2ools 提供的 '''__euca-describe-instances__''' 指令察看目前正在執行的 VM
{{{
$ euca-describe-instances
}}}
----
【Step 4:使用 Euca2ools 上傳 Kernel / Ramdisk / FS Image】
* 目前 Eucalyptus 系統上並無 Kernel、Ramdisk 和 FS Image,所以我們使用官方提供的 Image (上傳需要用到三個指令)
* '''__euca-bundle-image__''' - 打包好將要上傳的檔案
* '''__euca-upload-bundle__''' - 上傳到 Eucalyptus
* '''__euca-register__''' - 註冊上傳的檔案
* 上傳 Kernel
{{{
$ euca-bundle-image -i /boot/vmlinuz-2.6.26-2-xen-amd64 --kernel true
$ euca-upload-bundle -b kernel -m /tmp/vmlinuz-2.6.26-2-xen-amd64.manifest.xml
$ euca-register kernel/vmlinuz-2.6.26-2-xen-amd64.manifest.xml
}}}
* 上傳 Ramdisk
{{{
$ euca-bundle-image -i /boot/initrd.img-2.6.26-2-xen-amd64 --ramdisk true
$ euca-upload-bundle -b ramdisks -m /boot/initrd.img-2.6.26-2-xen-amd64.manifest.xml
$ euca-register ramdisks/initrd.img-2.6.26-2-xen-amd64.manifest.xml
}}}
* 上傳 FS Image
{{{
$ cd
$ wget http://eucalyptussoftware.com/downloads/eucalyptus-images/euca-debian-5.0-x86_64.tar.gz
$ tar zxvf euca-debian-5.0-x86_64.tar.gz
$ cd euca-debian-5.0-x86_64/
$ euca-bundle-image -i debian.5-0.x86-64.img
$ euca-upload-bundle -b images -m /tmp/debian.5-0.x86-64.img.manifest.xml
$ euca-register images/debian.5-0.x86-64.img.manifest.xml
}}}