Changes between Version 1 and Version 2 of YM_Course_2009/Lab9


Ignore:
Timestamp:
Jul 10, 2009, 6:04:18 PM (15 years ago)
Author:
jazz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • YM_Course_2009/Lab9

    v1 v2  
    66
    77◢ <[wiki:YM_Course_2009/Lab8 實作八]> | <[wiki:YM_Course_2009 回課程大綱]> ▲ | <[wiki:YM_Course_2009/Lab10 實作十]> ◣
     8
     9= 架設 BOINC Server =
     10
     11BOINC Server 的架設方式有兩種:
     12
     13 1. 使用 [http://boinc.berkeley.edu/trac/wiki/VirtualMachines BOINC 團隊提供的 VMWare Image] 進行測試
     14   * Linux 上如果遇到權限問題, 請確認解壓縮之後, vmx 檔案是否具備執行權限(Execution)
     15   * [狀況] 使用 [http://boincdl.ssl.berkeley.edu/dl/debian-40r0-i386-boinc.zip Berkeley Debian Etch 4.0r0 32bit], 網路卡一直無法正常啟動, 故轉而使用自行製作的 vmware image.
     16 2. 從 BOINC 官方 SVN 下載原始碼編譯並自行安裝相關套件
     17   * 使用自製 Debian Etch 4.0r0 版本的 Xen VM 並執行[#自行安裝 以下]的步驟
     18
     19== 使用 BOINC 官方 VMWare Image ==
     20
     21根據[http://boinc.berkeley.edu/trac/wiki/VirtualMachines 官方文件]的說明, 安裝 BONIC Server 最容易的方法是安裝[http://www.vmware.com/download/player/ VMWare player] (免費軟體/freeware)。目前有兩個 VMWare Image 可以下載:
     22
     23 * [http://boincdl.ssl.berkeley.edu/dl/debian-40r0-i386-boinc.zip Berkeley BOINC 團隊提供的 VMWare Image - Debian Etch 4.0r0 32bit]
     24 * [http://boincdl.ssl.berkeley.edu/dl/ubuntu-server-7.04-i386-boinc.zip Berkeley BOINC 團隊提供的 VMWare Image - Ubuntu Feisty 7.04 32-bit]
     25
     26== 自行安裝 ==
     27
     28=== 前置作業 ===
     29
     30 * 以下的步驟是在 Xen 的環境下完成, Xen 的安裝步驟請參考 [wiki:Xen_Installation Xen Installation How-To]
     31 * '''前置作業''': 建立 BOINC Server Xen VM (Etch)
     32{{{
     33xen-server:~# xen-create-image -dir /home/xen --dist etch --debootstrap --fs reiserfs --accounts --kernel /boot/vmlinuz-2.6.18-6-xen-vserver-amd64 --initrd /boot/initrd.img-2.6.18-6-xen-vserver-amd64 --hostname boinc-server --ip 140.110.X.X --gateway 140.110.X.X --netmask 255.255.255.0 --mirror http://free.nchc.org.tw/debian
     34xen-server:~# xm create /etc/xen/boinc-server.cfg
     35xen-server:~# xm list
     36Name                                      ID Mem(MiB) VCPUs State   Time(s)
     37Domain-0                                   0     1878     4 r-----   1478.4
     38bonic-server                               1      128     1 -b----   1035.7
     39}}}
     40 * 使用 root 帳號登入, 別忘了要設定密碼喔!! 否則用 xen-create-image 產生 VM 時請記得加 --passwd
     41{{{
     42xen-server:~# xm console bonic-server
     43boinc-server login: root
     44boinc-server:~# passwd
     45}}}
     46
     47
     48=== 安裝 BOINC Server 相關軟體 ===
     49
     50 * [參考文獻] [http://boinc.berkeley.edu/trac/wiki/ServerIntro#cookbook-debian40 Cookbook for Debian 4.0]
     51 *
     52 * BOINC Server 基本的套件需求
     53{{{
     54boinc-server:~# apt-get update
     55boinc-server:~# apt-get upgrade
     56boinc-server:~# apt-get install m4 make autoconf automake gcc g++ pkg-config libtool subversion vim apache2-mpm-prefork libapache2-mod-php5 mysql-server mysql-client-5.0 mysql-client-5.0 php5-mysql php5-cli php5-gd phpmyadmin python-mysqldb libmysql++-dev libssl-dev libphp-phpmailer
     57}}}
     58   * [備註] libphp-phpmailer - 供 BOINC 專案註冊帳號寄信用 (參考 Linux Magazine Issue 71 October 2006 "Building distributed application with BOINC"([http://www.linux-magazine.com/issue/71/Distributed_Applications_With_BOINC.pdf PDF Download]))
     59 * 建立 BOINC 管理者帳號
     60{{{
     61boinc-server:~# adduser boincadm
     62}}}
     63 * 修改 MySQL Server 預設 root 密碼
     64{{{
     65boinc-server:~# mysql_install_db
     66boinc-server:~# mysqladmin -h localhost -u root password '新的 MySQL Root 密碼'
     67}}}
     68 * 建立 BOINC SQL 管理者 boincadm 權限
     69{{{
     70boinc-server:~# mysql -h localhost -u root -p
     71mysql> GRANT ALL ON *.* TO 'boincadm'@'localhost';
     72mysql> SET PASSWORD FOR 'boincadm'@'localhost'='';
     73mysql> quit
     74}}}
     75 * 編譯 BOINC 原始檔
     76{{{
     77boinc-server:~# svn co http://boinc.berkeley.edu/svn/trunk/boinc boinc_trunk
     78boinc-server:~# cd ~/boinc_trunk
     79boinc-server:~/boinc_trunk# svn update
     80boinc-server:~/boinc_trunk# ./_autosetup
     81boinc-server:~/boinc_trunk# ./configure --disable-client --enable-unicode --without-x
     82boinc-server:~/boinc_trunk# make
     83}}}
     84
     85 * 建立 BOINC Project 範例
     86{{{
     87boinc-server:~# cd ~/boinc_trunk/tools
     88boinc-server:~/boinc_trunk/tools# ./make_project --url_base http://140.110.X.X/ --db_host localhost --db_user boincadm --project_root /var/www/boinc_projects --delete_prev_inst --drop_db_first --test_app bioinfo
     89boinc-server:~/boinc_trunk/tools# chown -R www-data:www-data /var/www/boinc_projects
     90boinc-server:~/boinc_trunk/tools# cd /var/www/boinc_projects
     91boinc-server:/var/www/boinc_projects# cp bioinfo.httpd.conf /etc/apache2/sites-available/bioinfo
     92boinc-server:/var/www/boinc_projects# ln -s /etc/apache2/sites-available/bioinfo /etc/apache2/sites-enabled/bioinfo
     93boinc-server:/var/www/boinc_projects# apache2ctl -t
     94boinc-server:/var/www/boinc_projects# apache2ctl restart
     95boinc-server:/var/www/boinc_projects# cat bioinfo.cronjob >> /var/spool/cron/crontabs/root
     96}}}
     97 * 由於範例專案預設不能申請帳號, 因此要把 disable_account_creation 的選項改為 0
     98{{{
     99#!diff
     100--- /var/www/boinc_projects/config.xml.org      2008-04-29 12:27:35.000000000 +0000
     101+++ /var/www/boinc_projects/config.xml  2008-04-29 11:54:40.000000000 +0000
     102@@ -17,7 +17,7 @@
     103       3
     104     </sched_debug_level>
     105     <disable_account_creation>
     106-      1
     107+      0
     108     </disable_account_creation>
     109     <uldl_dir_fanout>
     110       1024
     111}}}
     112 * 修改 project.xml 架構設定檔:可只留下 i686 Linux 跟 x86_64 Linux 兩種版本,也就是預設只有 Linux 32 位元跟 64 位元兩種 CPU 架構可以執行 uppercase 範例專案(與下一個步驟有關)
     113{{{
     114#!diff
     115--- /var/www/boinc_projects/project.xml.org     2008-05-07 18:49:53.000000000 -0700
     116+++ /var/www/boinc_projects/project.xml 2008-05-07 18:50:23.000000000 -0700
     117@@ -1,13 +1,5 @@
     118 <boinc>
     119     <platform>
     120-        <name>windows_intelx86</name>
     121-        <user_friendly_name>Microsoft Windows (98 or later) running on an Intel x86-compatible CPU</user_friendly_name>
     122-    </platform>
     123-    <platform>
     124-        <name>windows_x86_64</name>
     125-        <user_friendly_name>Microsoft Windows running on an AMD x86_64 or Intel EM64T CPU</user_friendly_name>
     126-    </platform>
     127-    <platform>
     128         <name>i686-pc-linux-gnu</name>
     129         <user_friendly_name>Linux running on an Intel x86-compatible CPU</user_friendly_name>
     130     </platform>
     131@@ -15,34 +7,6 @@
     132         <name>x86_64-pc-linux-gnu</name>
     133         <user_friendly_name>Linux running on an AMD x86_64 or Intel EM64T CPU</user_friendly_name>
     134     </platform>
     135-    <platform>
     136-        <name>powerpc-apple-darwin</name>
     137-        <user_friendly_name>Mac OS X 10.3 or later running on Motorola PowerPC</user_friendly_name>
     138-    </platform>
     139-    <platform>
     140-        <name>i686-apple-darwin</name>
     141-        <user_friendly_name>Mac OS 10.4 or later running on Intel</user_friendly_name>
     142-    </platform>
     143-    <platform>
     144-        <name>sparc-sun-solaris2.7</name>
     145-        <user_friendly_name>Solaris 2.7 running on a SPARC-compatible CPU</user_friendly_name>
     146-    </platform>
     147-    <platform>
     148-        <name>sparc-sun-solaris</name>
     149-        <user_friendly_name>Solaris 2.8 or later running on a SPARC-compatible CPU</user_friendly_name>
     150-    </platform>
     151-    <platform>
     152-        <name>sparc64-sun-solaris</name>
     153-        <user_friendly_name>Solaris 2.8 or later running on a SPARC 64-bit CPU</user_friendly_name>
     154-    </platform>
     155-    <platform>
     156-        <name>powerpc64-ps3-linux-gnu</name>
     157-        <user_friendly_name>Sony Playstation 3 running Linux</user_friendly_name>
     158-    </platform>
     159-    <platform>
     160-        <name>anonymous</name>
     161-        <user_friendly_name>anonymous</user_friendly_name>
     162-    </platform>
     163     <app>
     164         <name>uppercase</name>
     165         <user_friendly_name>upperCASE</user_friendly_name>
     166}}}
     167 * 確認範例專案的應用程式(BOINC Application)有 project.xml 中定義的二進位程式檔
     168{{{
     169boinc-server:/var/www/boinc_projects# cd apps/uppercase
     170boinc-server:/var/www/boinc_projects/apps/uppercase# ls
     171uppercase_1.1_i686-pc-linux-gnu
     172boinc-server:/var/www/boinc_projects/apps/uppercase# mkdir -p uppercase_1.1_x86_64-pc-linux-gnu
     173boinc-server:/var/www/boinc_projects/apps/uppercase# cp uppercase_1.1_i686-pc-linux-gnu/uppercase_1.1_i686-pc-linux-gnu uppercase_1.1_x86_64-pc-linux-gnu/uppercase_1.1_x86_64-pc-linux-gnu
     174}}}
     175   * 注意:目錄的命名法則為『應用程式名稱_版本_CPU架構-作業系統』,而二進位程式檔的『版本』、『CPU架構』及『作業系統』都必須與目錄一致,也必須跟 project.xml 中寫的一致(參考 BOINC 官方網站註明的『已支援CPU架構、作業系統』),否則會在執行 bin/update_versions 時出現錯誤。
     176{{{
     177boinc-server:/var/www/boinc_projects# bin/update_versions
     178  Ignoring directory (no main program found - it has to be named the same as the directory) /var/www/boinc_projects/apps/uppercase/uppercase_1.1_x86_64-pc-linux-gnu
     179No new versions found!
     180}}}
     181 * 編輯專案網頁相關設定 html/project/project.inc
     182{{{
     183#!diff
     184--- project.inc.org     2008-05-07 19:33:47.000000000 -0700
     185+++ project.inc 2008-05-07 19:36:00.000000000 -0700
     186@@ -7,7 +7,7 @@
     187 require_once("../inc/util.inc");
     188
     189 $master_url = parse_config(get_config(), "<master_url>");
     190-define("PROJECT", "REPLACE WITH PROJECT NAME");
     191+define("PROJECT", "Bioinfo@Home");
     192 define("URL_BASE", $master_url);
     193 define("IMAGE_PATH", "../user_profile/images/");
     194 define("IMAGE_URL", "user_profile/images/");
     195@@ -15,14 +15,14 @@
     196 define("PROFILE_URL", "user_profile/");
     197 define("LANGUAGE_FILE", "languages.txt");
     198 define("STYLESHEET", "white.css");
     199-define("COPYRIGHT_HOLDER", "REPLACE WITH COPYRIGHT HOLDER");
     200-define("SYS_ADMIN_EMAIL", "admin@$master_url");
     201-define("UOTD_ADMIN_EMAIL", "admin@$master_url");
     202+define("COPYRIGHT_HOLDER", "NCHC,Taiwan");
     203+define("SYS_ADMIN_EMAIL", "YOURNAME@NCHC.ORG.TW");
     204+define("UOTD_ADMIN_EMAIL", "YOURNAME@NCHC.ORG.TW");
     205     // who gets user of the day pool running low e-mails?
     206
     207 // Email addresses separated by pipe ( | ) that will receive user reported
     208 // offensive forum posts.
     209-define("POST_REPORT_EMAILS", "moderator1@$master_url|moderator2@$master_url");
     210+define("POST_REPORT_EMAILS", "YOURNAME@NCHC.ORG.TW|YOURNAME2@NCHC.ORG.TW");
     211
     212 function project_banner($title) {
     213     // Put your project title and logo here
     214}}}
     215 * 啟動範例專案
     216{{{
     217boinc-server:/var/www/boinc_projects# bin/xadd
     218boinc-server:/var/www/boinc_projects# bin/update_versions
     219boinc-server:/var/www/boinc_projects# bin/start
     220boinc-server:/var/www/boinc_projects# bin/status
     221}}}
     222 * 檢視 BOINC Project 範例
     223   * 專案計畫首頁 - http://140.110.X.X/bioinfo
     224   * 專案管理首頁 - http://140.110.X.X/bioinfo_ops/
     225
     226== 測試 BOINC Project 範例 ==
     227
     228 * STEP 1: 首先安裝 boinc-client
     229{{{
     230boinc-client:~# apt-get install boinc-client
     231}}}
     232 * STEP 2: 其次是前往 http://140.110.X.X/bioinfo/create_account_form.php 註冊帳號
     233   * 取得 Account key , 例如: 8346cd95017b110ee2ecd88ed7734981
     234   * [備註] 相同的資訊可以登入後, 在 http://140.110.X.X/bioinfo/home.php 取得
     235   * 亦可使用命令列取得 Account key
     236{{{
     237boinc-client:~# boinc_cmd --create_account http://140.110.X.X/bioinfo ${YOUR_EMAIL} "${YOUR_PASSWORD}" ${YOUR_ID}
     238status: Success
     239poll status: operation in progress
     240poll status: operation in progress
     241account key: 8346cd95017b110ee2ecd88ed7734981
     242}}}
     243 * STEP 3: 測試 boinc-client 登入 BOINC Project 範例
     244   * [方法一] 直接執行 boinc
     245{{{
     246boinc-client:~# boinc -attach_project http://140.110.X.X/bioinfo 8346cd95017b110ee2ecd88ed7734981 &
     247########################### 說明 #########################################
     248boinc-server:~# boinc -attach_project ${專案網址} ${線上申請到的_Account_key} &
     249}}}
     250   * [方法二] 讓 boinc-client 跑在背景, 再用 boinc_cmd 去加入 project
     251{{{
     252boinc-client:~# /etc/init.d/boinc-client start
     253##### 加入專案 #####
     254boinc-client:~# boinc_cmd --project_attach http://140.110.X.X/bioinfo 8346cd95017b110ee2ecd88ed7734981
     255##### 取得狀態 #####
     256boinc-client:~# boinc_cmd --get_state
     257##### 離開專案 #####
     258boinc-client:~# boinc_cmd --project http://140.110.X.X/bioinfo detach
     259}}}
     260
     261== 錯誤排除 ==
     262
     263 * [狀況一] 當 boinc client 加入專案後, 一直無法取得系統狀態. 查看 /var/lib/boinc_client/sched_replay_* 出現以下訊息
     264{{{
     265}}}
     266 * [參考] [http://scilincdev.blogspot.com/2006/12/boinc-server-shared-memory-error.html BOINC Server Shared Memory Error]