Changes between Initial Version and Version 1 of III120526/Lab8


Ignore:
Timestamp:
May 27, 2012, 3:23:21 PM (13 years ago)
Author:
jazz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • III120526/Lab8

    v1 v1  
     1◢ <[wiki:III120526/Lab7 實作七]> | <[wiki:III120526 回課程大綱]> ▲ | <[wiki:III120526/Lab9 實作九]> ◣
     2
     3= 實作八 Lab 8 =
     4[[PageOutline]]
     5{{{
     6#!html
     7<div style="text-align: center;"><big style="font-weight: bold;"><big>在完全分散模式下編譯 MapReduce 程式<br/>Compiling Hadoop MapReduce Java Program in Hadoop Cluster</big></big></div>
     8}}}
     9
     10{{{
     11#!text
     12以下練習,請連線至 hadoop.nchc.org.tw 操作。底下的 hXXXX 等於您的用戶名稱。
     13}}}
     14
     15= Practice 1 : Word Count (Basic) =
     16
     17 * 上傳內容到 HDFS 內[[BR]]upload data to HDFS
     18{{{
     19$ mkdir lab8_input
     20$ echo "I like NCTU Cloud Course." > lab8_input/input1
     21$ echo "I like nctu Cloud Course, and we enjoy this course." > lab8_input/input2
     22$ hadoop fs -put lab8_input lab8_input
     23$ hadoop fs -ls lab8_input
     24Found 2 items
     25-rw-r--r--   2 hXXXX supergroup         26 2011-04-19 10:07 /user/hXXXX/lab8_input/input1
     26-rw-r--r--   2 hXXXX supergroup         52 2011-04-19 10:07 /user/hXXXX/lab8_input/input2
     27}}}
     28
     29 * 下載 [http://hadoop.nchc.org.tw/WordCount.java WordCount.java] 並存到家目錄;[[BR]]Download [http://hadoop.nchc.org.tw/WordCount.java WordCount.java] and save to your home directory
     30{{{
     31~$ wget http://hadoop.nchc.org.tw/WordCount.java
     32}}}
     33
     34 * 運作程式[[BR]]Compile WordCount.java and run it by '''hadoop jar''' command
     35
     36{{{
     37$ mkdir MyJava
     38$ ln -s /usr/lib/hadoop/hadoop-*-core.jar hadoop-core.jar
     39$ javac -classpath hadoop-core.jar -d MyJava WordCount.java
     40$ jar -cvf wordcount.jar -C MyJava .
     41$ hadoop jar wordcount.jar WordCount lab8_input/ lab8_out1/
     42$ hadoop fs -cat lab8_out1/part-00000
     43}}}
     44
     45 * lab8_out1 執行結果 [[BR]]You should see results like this :
     46{{{
     47#!text
     48Cloud   2
     49Course, 1
     50Course. 1
     51I       2
     52NCTU    1
     53and     1
     54course. 1
     55enjoy   1
     56like    2
     57nctu    1
     58this    1
     59we      1
     60}}}
     61-----
     62
     63= Practice 2 : Word Count (Advanced) =
     64
     65{{{
     66$ echo "\." >pattern.txt && echo "\," >>pattern.txt
     67$ hadoop fs -put pattern.txt .
     68$ mkdir -p MyJava2
     69}}}
     70
     71
     72 * 下載 [http://hadoop.nchc.org.tw/WordCount2.java WordCount2.java] 並存到家目錄;[[BR]]Download [http://hadoop.nchc.org.tw/WordCount2.java WordCount2.java] to home directory
     73{{{
     74~$ wget http://hadoop.nchc.org.tw/WordCount2.java
     75}}}
     76
     77{{{
     78$ javac -classpath hadoop-core.jar -d MyJava2 WordCount2.java
     79$ jar -cvf wordcount2.jar -C MyJava2 .
     80$ hadoop jar wordcount2.jar WordCount2 lab8_input lab8_out2 -skip pattern.txt
     81$ hadoop fs -cat lab8_out2/part-00000
     82}}}
     83
     84 * lab8_out2 執行結果[[BR]]You should see results like this:
     85{{{
     86#!text
     87Cloud   2
     88Course  2
     89I       2
     90NCTU    1
     91and     1
     92course  1
     93enjoy   1
     94like    2
     95nctu    1
     96this    1
     97we      1
     98}}}
     99
     100 * Let's given case insensitive and ignore pattern for this example
     101{{{
     102$ hadoop jar wordcount2.jar WordCount2 -Dwordcount.case.sensitive=false lab8_input lab8_out3 -skip pattern.txt
     103$ hadoop fs -cat lab8_out3/part-00000
     104}}}
     105
     106 * lab8_out3 執行結果[[BR]]You should see results like this:
     107{{{
     108#!text
     109and     1
     110cloud   2
     111course  3
     112enjoy   1
     113i       2
     114like    2
     115nctu    2
     116this    1
     117we      1
     118}}}