[[PageOutline]] = Building ClassCloud Live CD = '''ClassCloud-LiveCD : 基於 DRBL 的雲端教學環境''' == 緣起 == * [緣起] 昨晚(2010-05-16)想了很久,或許開始動手寫 code 比規劃半天有用。本想用 Chromium OS 來改,因為它也是基於 Ubuntu/Debian 系列,不過看了 penk 的 [http://penkia.blogspot.com/2010/02/xpud-chromium-os.html xPUD 火力展示:全世界最小的 Chromium OS (58MB)],並考量可能會需要一些 base system 跟 firefox 中鑲嵌 terminal 的需求,決定還是用 [http://www.xpud.org xPUD] 的 [http://github.com/penk/mkxpud mkxpud] 來作好了。 * [參考] 先前研究 xPUD 的紀錄 - [wiki:jazz/09-04-16#xPUD 2009-04-16] * 使用 Xvesa 當 X server - 看起來不是套件 [http://packages.debian.org/lenny/xserver-xorg-video-vesa xserver-xorg-video-vesa] 裡的 - 待追蹤 * 採用輕量級的視窗管理(Window Manager) - [http://packages.debian.org/lenny/openbox OpenBox] * 把程式鑲在 Mozilla 裡面的工具叫做 [http://packages.debian.org/lenny/mozplugger mozplugger] -- 這個是目前主要的考量。 * [參考] 精簡執行 x-windows 所需的套件環境 - 參考 [wiki:jazz/09-02-09 2009-02-09 Atom + AIR 的實驗] * [參考] 快速開機(Fast Booting)相關參考連結 - 參考 [wiki:jazz/09-05-08#FastBoot 2009-05-08 Fast Booting 筆記] == 2010-05-17 == === xPUD === * 測試環境:Debian GNU/Linux 5.0.4 (lenny) {{{ jazz@Wdebian:~$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 5.0.4 (lenny) Release: 5.0.4 Codename: lenny }}} * 取得 xPUD [http://github.com/penk/mkxpud mkxpud] 原始碼 - (1) 先安裝 git (注意套件名稱是 git-core 不是 git 喔!!) (2) 從 github 下載原始碼 {{{ jazz@Wdebian:~$ sudo apt-get install git-core jazz@Wdebian:~$ git clone git://github.com/penk/mkxpud.git }}} * 由於會使用到 mksqushfs 跟 mkiofs 指令,因此就必須安裝 squashfs-tools 與 mkisofs 兩個套件。另外,因為會用到 ttf-droid 套件,只有 Ubuntu 有包,Debian 沒有,所以就只好從 Ubuntu 借了。 {{{ jazz@Wdebian:~$ http://mirrors.kernel.org/ubuntu/pool/universe/t/ttf-droid/ttf-droid_1.00~b112+dfsg+1-0ubuntu1_all.deb jazz@Wdebian:~$ dpkg -i ttf-droid_1.00~b112+dfsg+1-0ubuntu1_all.deb jazz@Wdebian:~$ sudo apt-get install squashfs-tools mkisofs jazz@Wdebian:~$ cd mkxpud/ jazz@Wdebian:~/mkxpud$ sudo ./tools/mkxpud all }}} * [結果] 失敗!!! 看樣子 xPUD 的 mkxpud 一定得在 Ubuntu 系列執行才可以 :( - 沒仔細看文件的下場 .... {{{ To generate a xPUD image, you will need: 1. a working Ubuntu 9.10 installation <---------------- ㄜ!!!! 2.6.28.cookbook jaunty.cookbook xpud089.cookbook default.cookbook lucid.cookbook 都是 ubuntu 系列 2. sudo permission to install packages on the host and testing 3. Internet access to download packages (if required) 4. at least 500MB of hard disk free space }}} * 改到 Ubuntu 9.04 試試看~因為從 xpud.org 下載 xpud-2.6.31.2-mod.tgz 很慢,所以嘗試從 [http://mesrss.free.fr/xpud/ mirror site]下載,並解開至 /lib/modules/2.6.31.2 這樣 mkxpud 的 script 才不會又下載一次。安裝 squshfs-tools 跟 genisoimage (mkisofs) 供產生 Live CD ROOTFS 與 ISO 檔用,安裝 qemu 供 mkxpud test 用,安裝 nsis 好像是為了產生 windows exe 安裝執行檔。 {{{ jazz@jazzbook:~/mkxpud$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 9.04 Release: 9.04 Codename: jaunty jazz@jazzbook:~/mkxpud$ sudo apt-get install qemu squashfs-tools genisoimage nsis jazz@jazzbook:~/mkxpud$ sudo wget http://mesrss.free.fr/xpud/archive/xpud-2.6.31.2-mod.tgz -P skeleton/archive/ jazz@jazzbook:~/mkxpud$ sudo tar xzf skeleton/archive/xpud-2.6.31.2-mod.tgz -C / jazz@jazzbook:~/mkxpud$ sudo ./tools/mkxpud all }}} === DRBL-Live === * 好吧,那改試一下先前搞不定的 create-drbl-live 好了,今天總算看清楚文件,有幾個小細節要注意: * 要先裝 live helper 與 cdebootstrap ('''這兩個都要使用 DRBL patch 過的版本''')才能使用 * 下載 clonezilla live 1.2.2-31 (用 '''1.2.3-x''' 的版本還不能適用) * 也難怪以前老是弄不出來了 :( * 開始動作 - [參考] [wiki:jazz/09-08-03#DRBL-HadoopLive 2009-08-03 的紀錄] 跟 進階課程的說明 『[http://drbl.nchc.org.tw/advanced/fine-print.php?path=./01_DRBL/09-drbl-live.faq#09-drbl-live.faq 從無到有製作DRBL live]』 {{{ ~$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 5.0.4 (lenny) Release: 5.0.4 Codename: lenny ~$ echo "deb http://free.nchc.org.tw/drbl-core drbl live-unstable live-testing live-experimental live-stable stable testing unstable" > drbl.list ~$ sudo mv drbl.list /etc/apt/sources.list.d/ ~$ sudo apt-get update ~$ wget http://drbl.nchc.org.tw/GPG-KEY-DRBL ~$ sudo apt-key add GPG-KEY-DRBL ~$ sudo apt-get update ~$ sudo apt-get -y install drbl clonezilla live-helper cdebootstrap zip ~$ sudo /opt/drbl/sbin/drblsrv -i ~$ sudo /opt/drbl/sbin/drblpush -i ~$ sudo /opt/drbl/sbin/create-drbl-live-by-pkg -m http://free.nchc.org.tw/debian -s http://free.nchc.org.tw/debian-security -e unstable }}} * 根據 [attachment:10-05-17_err.log 編譯時的錯誤訊息] 可以知道最好還是跑過 drblsrv -i 跟 drblpush -i 之後再來產生 DRBL Live CD 才會正確。 == 2010-05-18 == * 整理快速開機(Fast Booting)相關歷史紀錄 - 參考 [wiki:jazz/09-05-08#FastBoot 2009-05-08 Fast Booting 筆記] * 用 QEMU 測試 xPUD 產生的 iso 檔 - [結果] 卡在 * [[Image(jazz/ClassCloud_LiveCD:10-05-18_xpud.png)]] * 2010-05-21: 發現這是 ubuntu qemu package 的問題 - [https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/379000 qemu bug#379000] == 2010-05-19 == * 修正作法, 再試一次 create-drbl-live-by-pkg : {{{ ~$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 5.0.4 (lenny) Release: 5.0.4 Codename: lenny ~$ echo "deb http://free.nchc.org.tw/drbl-core drbl stable" > drbl.list ~$ sudo mv drbl.list /etc/apt/sources.list.d/ ~$ wget http://drbl.nchc.org.tw/GPG-KEY-DRBL ~$ sudo apt-key add GPG-KEY-DRBL ~$ sudo apt-get update ~$ sudo apt-get -y install drbl ~$ sudo /opt/drbl/sbin/drblsrv -i -c n -n n -m n -g n -k 2 -o 1 ~$ echo "deb http://free.nchc.org.tw/drbl-core drbl live-unstable" > drbl-live.list ~$ sudo mv drbl-live.list /etc/apt/sources.list.d/ ~$ sudo apt-get update ~$ sudo apt-get -y install live-helper cdebootstrap zip ~$ sudo /opt/drbl/sbin/create-drbl-live-by-pkg -m http://free.nchc.org.tw/debian -s http://free.nchc.org.tw/debian-security -e unstable }}} * Yeah!! 成功了!! {{{ jazz@lenny:~$ ls drbl-live-xfce-20100519.iso drbl-live-xfce-stage1-20100519.iso drbl-live-xfce-20100519.zip GPG-KEY-DRBL }}} == 2010-05-21 == * 基於 create-drbl-live-by-pkg 開始嘗試加入 jdk, hadoop, xen hypervisor 套件....[失敗] * [原因] sun-java6-jdk 等套件必須選擇同意授權才能繼續安裝。(2010-05-30 解決) == 2010-05-23 == * [文件] drbl-live 是用 live-helper 做的,所以相關語法可以參考 [http://live.debian.net/manual/html/index.html Debian Live Manual] * 研究 live-helper 跟 create-drbl-live * lh_build 指令會執行三個 Stage,依序為 lh_bootstrap、lh_chroot 與 lh_binary {{{ lh_bootstrap - create the first stage by bootstrapping a basic debian system lh_chroot - create the second stage by customizing the chroot lh_binary - create the third stage by generating a binary image }}} * 如果要用 live-helper 產生 live cd 並且用更多 apt 來源,可在 config/chroot_sources/ 加入 live.chroot 、 live.binary 跟對應的 gpg key 在 live.chroot.gpg 、live.binary.gpg * 要額外裝的套件,可以參考 /usr/share/live-helper/lists/ 底下的檔案。然後用 lh config --bootstrap-config FILE 來指定。預設是使用 /usr/share/live-helper/lists/standard {{{ LH_PACKAGES_LISTS="standard" }}} * 要額外拷貝進 Live CD 的檔案,可放在 config/chroot_local-includes * 必須注意的是若跑過 lh_build 之後才更動 config/chroot_local-includes 的內容,必須下 lh_clean --chroot 把 chroot 目錄清除才能成功地更新檔案內容。當然最乾淨的做法是 lh_clean --purge 會全部清掉(除了 config 目錄外) * 撰寫 drbl-hadoop-live 測試程式 [source:drbl-hadoop-live/test-live-helper.sh test-live-helper.sh] [147][148] == 2010-05-30 == * 解決 2010-05-21 的問題 - Debian / Ubuntu 如何在 shell script 裡面安裝 sun-java6-jdk 又不用選 yes 呢?! * [參考] [http://www.davidpashley.com/blog/debian/java-license Installing java non-interactively] * 這裡提到用 debconf-set-selections 來設定一些參數,讓 sun-java*-* 不問授權的 yes,方法包括有寫檔跟沒寫檔的做法,個人覺得留言裡面的那個做法最帥了!! {{{ cat << EOF | /usr/bin/debconf-set-selections sun-java6-bin shared/accepted-sun-dlj-v1-1 select true sun-java6-jdk shared/accepted-sun-dlj-v1-1 select true sun-java6-jre shared/accepted-sun-dlj-v1-1 select true EOF }}} * 那麼如果以後遇到別的套件也有類似的問題該怎麼找參數呢?? 答案是用 debconf-get-selections 這個指令,首先必須安裝 [http://packages.debian.org/debconf-utils debconf-utils] 套件,然後執行 debconf-get-selections 再用 grep 用套件名稱找出可以改的參數。 {{{ ~$ sudo debconf-get-selections | grep sun-java6 sun-java6-jre sun-java6-jre/stopthread boolean true sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true sun-java6-jre sun-java6-jre/jcepolicy note sun-java6-bin shared/error-sun-dlj-v1-1 error sun-java6-jre shared/error-sun-dlj-v1-1 error sun-java6-bin shared/present-sun-dlj-v1-1 note sun-java6-jre shared/present-sun-dlj-v1-1 note }}} * 須注意的是原本參數是 boolean 格式,若要下給 debconf-set-selections 必須置換成 select 關鍵字喔!! {{{ ~$ sudo debconf-get-selections | grep sun-java6 | grep boolean | sed 's#boolean#select#g' sun-java6-bin shared/accepted-sun-dlj-v1-1 select true sun-java6-jdk shared/accepted-sun-dlj-v1-1 select true sun-java6-jre shared/accepted-sun-dlj-v1-1 select true sun-java6-jre sun-java6-jre/stopthread select true }}} == 2010-06-25 == * 更新 drbl-hadoop-live 測試程式 [source:drbl-hadoop-live/test-live-helper.sh test-live-helper.sh] [149] * [備忘] lh config 的 --categories 參數只有在 1.0.3-2 有,2.0~a11-1drbl1 反而沒有 {{{ jazz@lenny:~/drbl-hadoop-live$ dpkg -l live-helper 要求=U:未知/I:安裝/R:刪除/P:清除/H:保留 | 狀態=N:尚未/I:已安裝/C:設定檔/U:已解開/F:設定失敗/H:半安裝/W:待處理/T:未處理 |/ 錯誤?=(無)/H:保留/R:須重新安裝/X:兩者兼有(狀態,錯誤:大寫=有問題) ||/ 名稱 版本 簡介 +++-================-================-================================================ ii live-helper 1.0.3-2 Debian Live build scripts jazz@lenny:~/drbl-hadoop-live$ sudo lh config --help | grep "cat" [--iso-application NAME] [--categories CATEGORY|"CATEGORIES"] }}} {{{ jazz@Wdebian:~$ dpkg -l live-helper Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ 名稱 版本 簡介 +++-================-================-================================================ ii live-helper 2.0~a11-1drbl1 Debian Live build scripts jazz@Wdebian:~$ sudo lh config --help | grep "cat" [sudo] password for jazz: [--iso-application NAME] }}} * 由於 live-helper 會產生 .stage 的檔案,所以可以用時間戳記來了解 live-helper 的大致工作流程(workflow) {{{ jazz@lenny:~/drbl-hadoop-live/.stage$ ls --full-time * | sort -n -rw-r--r-- 1 root root 0 2010-06-26 09:40:34.000000000 +0800 config -rw-r--r-- 1 root root 0 2010-06-26 09:42:44.000000000 +0800 bootstrap -rw-r--r-- 1 root root 0 2010-06-26 09:42:45.000000000 +0800 bootstrap_cache.save -rw-r--r-- 1 root root 0 2010-06-26 09:43:05.000000000 +0800 chroot_packageslists -rw-r--r-- 1 root root 0 2010-06-26 09:43:06.000000000 +0800 chroot_packages -rw-r--r-- 1 root root 0 2010-06-26 09:45:58.000000000 +0800 chroot_install-packages -rw-r--r-- 1 root root 0 2010-06-26 09:46:02.000000000 +0800 chroot_localization -rw-r--r-- 1 root root 0 2010-06-26 09:46:05.000000000 +0800 chroot_hacks -rw-r--r-- 1 root root 0 2010-06-26 09:46:30.000000000 +0800 binary_chroot -rw-r--r-- 1 root root 0 2010-06-26 09:46:41.000000000 +0800 chroot_apt -rw-r--r-- 1 root root 0 2010-06-26 09:48:51.000000000 +0800 binary_rootfs -rw-r--r-- 1 root root 0 2010-06-26 09:48:52.000000000 +0800 binary_manifest -rw-r--r-- 1 root root 0 2010-06-26 09:48:53.000000000 +0800 binary_linux-image -rw-r--r-- 1 root root 0 2010-06-26 09:49:00.000000000 +0800 binary_memtest -rw-r--r-- 1 root root 0 2010-06-26 09:49:07.000000000 +0800 binary_syslinux -rw-r--r-- 1 root root 0 2010-06-26 09:49:08.000000000 +0800 binary_disk -rw-r--r-- 1 root root 0 2010-06-26 09:49:08.000000000 +0800 binary_win32-loader -rw-r--r-- 1 root root 0 2010-06-26 09:49:09.000000000 +0800 binary_includes -rw-r--r-- 1 root root 0 2010-06-26 09:49:11.000000000 +0800 binary_md5sum -rw-r--r-- 1 root root 0 2010-06-26 09:49:17.000000000 +0800 binary_iso }}} == 2010-06-28 == * 整理 live-helper stage 產生順序,以釐清各階段怎麼執行。 {{{ #!graphviz digraph "live-helper" { node [shape=record,width=10]; struct1 [label=" 1. lh_config |{ 2. lh_build |{ 2.1 lh_bootstrap | | 2.2 lh_chroot | | 2.3 lh_binary }}"]; node [shape=box,width=2]; rankdir=TD; struct1:f1 -> "config"; struct1:f3->"bootstrap"->"bootstrap_cache.save"; struct1:f4->"chroot_packageslists"->"chroot_packages"->"chroot_install-packages"->"chroot_localization"->"chroot_hacks"->"binary_chroot"->"chroot_apt"; struct1:f5->"binary_rootfs"->"binary_manifest"->"binary_linux-image"->"binary_memtest"->"binary_syslinux"->"binary_disk"->"binary_win32-loader"->"binary_includes"->"binary_md5sum"->"binary_iso"; } }}} * 更新 drbl-hadoop-live 測試程式 [source:drbl-hadoop-live/test-live-helper.sh test-live-helper.sh] [150] * lenny 5.0.5 測試 {{{ jazz@lenny:~$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 5.0.5 (lenny) Release: 5.0.5 Codename: lenny jazz@lenny:~$ sudo apt-get update; sudo apt-get upgrade jazz@lenny:~$ sudo apt-get install live-helper subversion make jazz@lenny:~$ svn co https://trac.nchc.org.tw/svn/grid/drbl-hadoop-live jazz@lenny:~$ svn co http://trac.nchc.org.tw/pub/grid/drbl-hadoop-live jazz@lenny:~$ cd drbl-hadoop-live/ jazz@lenny:~/drbl-hadoop-live$ make }}} == 2010-06-29 == * 測試 chroot-hook 與 binary-hook 的差異 * 更新 drbl-hadoop-live 測試程式 [source:drbl-hadoop-live/test-live-helper.sh test-live-helper.sh] [151] * 嘗試將安裝 java 的步驟加進 create-drbl-live-by-pkg == 2010-06-30 == * 嘗試將安裝 java 的步驟加進 create-drbl-live-by-pkg - 成功!! (鬧了個小烏龍,昨天一直忘記改 create-hadoop-live-by-pkg 裡的 create-drbl-live 成 create-hadoop-live,難怪一直弄不出來。 * 新增 [source:drbl-hadoop-live/create-hadoop-live-by-pkg create-hadoop-live-by-pkg], [source:drbl-hadoop-live/create-hadoop-live create-hadoop-live], 與 [source:drbl-hadoop-live/hadoop-live-hook hadoop-live-hook] [152] == 2010-07-13 == * 修改 [source:drbl-hadoop-live/create-hadoop-live create-hadoop-live] 與 [source:drbl-hadoop-live/hadoop-live-hook hadoop-live-hook] [153] * 加入安裝 Cloudera's Distribution For Hadoop (CDH2) 的 script == 2010-07-16 == * 一直測不出來,原來 Makefile 順序寫錯 :( * 更新 [source:drbl-hadoop-live/create-hadoop-live create-hadoop-live] 與 [source:drbl-hadoop-live/Makefile Makefile] [154] * 終於成功地在 DRBL Live CD 加入 JDK 與 CDH2 了....有圖有真相!! * [[Image(10-07-16_hadoop-live_v0.1.0.jpg,width=600)]] * 下一步:模仿 drbl-live.sh 寫一隻 hadoop-live.sh 來佈署多台 DRBL Client as Hadoop tasktracker 跟 datanode == 2010-07-19 == * [http://sourceforge.net/projects/drbl-hadoop/files/0.1.0/hadoop-live-xfce-20100717.iso/download 釋出 DRBL-Hadoop Live CD 0.1.0 版本] == 2010-07-20 == * 加入預設單機執行(Single Node)的 hadoop 相關 service, 可是卻出現啟動時的錯誤訊息 * [[Image(10-07-20_hadoop-init-error.jpg,width=600)]] * 縱使是在 VM 裡面直接裝 CDH2 也一樣會有這樣的錯誤訊息,因此應該是 script 本身的問題(不該用相對路徑).