Changes between Initial Version and Version 1 of Hadoop_Lab4


Ignore:
Timestamp:
Aug 28, 2009, 6:19:09 PM (15 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Hadoop_Lab4

    v1 v1  
     1{{{
     2#!html
     3<div style="text-align: center;"><big
     4 style="font-weight: bold;"><big><big>實做四: Hadoop 程式編譯</big></big></big></div>
     5}}}
     6[[PageOutline]]
     7
     8
     9== 前言:啟動Hadoop環境 ==
     10 
     11 * 重新啟動昨天的環境
     12   * 在 node1 上操作
     13{{{
     14$ cd ~
     15$ wget http://hadoop.nchc.org.tw/~waue/clean.sh
     16$ chmod 755 clean.sh
     17$ ./clean.sh
     18$
     19}}}
     20   * 請檢查 hadoop 是否正確運作.
     21
     22 == 練習 1 : Word Count 初級版 ==
     23
     24 * 上傳內容到hdfs內
     25
     26{{{
     27$ cd /opt/hadoop
     28$ bin/hadoop fs -mkdir input
     29$ echo "I like NCHC Cloud Course." > input1
     30$ echo "I like nchc Cloud Course, and we enjoy this course." > input2
     31$ bin/hadoop fs -put input1 input
     32$ bin/hadoop fs -put input2 input
     33$ bin/hadoop fs -ls input
     34}}}
     35
     36 * 點此連結 [attachment:wiki:jazz/Hadoop_Lab6:WordCount.java?format=raw WordCount.java] 並將他存到 /opt/hadoop;
     37
     38
     39 * 運作程式
     40
     41{{{
     42$ mkdir MyJava
     43$ javac -classpath hadoop-*-core.jar -d MyJava WordCount.java
     44$ jar -cvf wordcount.jar -C MyJava .
     45$ bin/hadoop jar wordcount.jar WordCount input/ output/
     46$ bin/hadoop fs -cat output/part-00000
     47}}}
     48
     49-----
     50
     51 == 練習 2 : Word Count 進階版 ==
     52
     53{{{
     54$ echo "\." >pattern.txt && echo "\," >>pattern.txt
     55$ bin/hadoop fs -put pattern.txt ./
     56$ mkdir MyJava2
     57}}}
     58
     59 * 點此連結 [attachment:wiki:jazz/Hadoop_Lab6:WordCount2.java?format=raw WordCount2.java] 並將他存到 /opt/hadoop;
     60
     61{{{
     62$ javac -classpath hadoop-*-core.jar -d MyJava2 WordCount2.java
     63$ jar -cvf wordcount2.jar -C MyJava2 .
     64$ bin/hadoop jar wordcount2.jar WordCount2 input output2 -skip pattern.txt
     65$ bin/hadoop fs -cat output2/part-00000
     66$ bin/hadoop jar wordcount2.jar WordCount2 -Dwordcount.case.sensitive=false input output3 -skip pattern.txt
     67$ bin/hadoop fs -cat output3/part-00000
     68}}}