Changes between Version 1 and Version 2 of NCTU110329/Lab6
- Timestamp:
- Apr 19, 2011, 10:53:52 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
NCTU110329/Lab6
v1 v2 15 15 16 16 {{{ 17 $ cd /opt/hadoop 18 $ mkdir lab4_input 19 $ echo "I like NCHC Cloud Course." > lab4_input/input1 20 $ echo "I like nchc Cloud Course, and we enjoy this course." > lab4_input/input2 21 $ bin/hadoop fs -put lab4_input lab4_input 22 $ bin/hadoop fs -ls lab4_input 17 $ mkdir lab6_input 18 $ echo "I like NCTU Cloud Course." > lab6_input/input1 19 $ echo "I like nctu Cloud Course, and we enjoy this course." > lab6_input/input2 20 $ hadoop fs -put lab6_input lab6_input 21 $ hadoop fs -ls lab6_input 22 Found 2 items 23 -rw-r--r-- 2 hXXXX supergroup 26 2011-04-19 10:07 /user/hXXXX/lab6_input/input1 24 -rw-r--r-- 2 hXXXX supergroup 52 2011-04-19 10:07 /user/hXXXX/lab6_input/input2 23 25 }}} 24 26 25 * 下載 [http:// secuse.nchc.org.tw/class/WordCount.java WordCount.java] 並存到/opt/hadoop;[[BR]]Download [http://trac.nchc.org.tw/cloud/raw-attachment/wiki/WordCount/WordCount.java WordCount.java] and save to /opt/hadoop27 * 下載 [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 26 28 {{{ 27 ~$ cd /opt/hadoop 28 /opt/hadoop$ wget http://trac.nchc.org.tw/cloud/raw-attachment/wiki/WordCount/WordCount.java 29 ~$ wget http://hadoop.nchc.org.tw/WordCount.java 29 30 }}} 30 31 … … 33 34 {{{ 34 35 $ mkdir MyJava 35 $ javac -classpath hadoop-*-core.jar -d MyJava WordCount.java 36 $ ln -s /usr/lib/hadoop/hadoop-*-core.jar hadoop-core.jar 37 $ javac -classpath hadoop-core.jar -d MyJava WordCount.java 36 38 $ jar -cvf wordcount.jar -C MyJava . 37 $ bin/hadoop jar wordcount.jar WordCount lab4_input/ lab4_out1/38 $ bin/hadoop fs -cat lab4_out1/part-0000039 $ hadoop jar wordcount.jar WordCount lab6_input/ lab6_out1/ 40 $ hadoop fs -cat lab6_out1/part-00000 39 41 }}} 40 42 41 * lab 4_out1 執行結果 [[BR]]You should see results like this :43 * lab6_out1 執行結果 [[BR]]You should see results like this : 42 44 {{{ 43 45 #!text … … 46 48 Course. 1 47 49 I 2 48 NC HC150 NCTU 1 49 51 and 1 50 52 course. 1 51 53 enjoy 1 52 54 like 2 53 nc hc155 nctu 1 54 56 this 1 55 57 we 1 … … 61 63 {{{ 62 64 $ echo "\." >pattern.txt && echo "\," >>pattern.txt 63 $ bin/hadoop fs -put pattern.txt ./64 $ mkdir MyJava265 $ hadoop fs -put pattern.txt . 66 $ mkdir -p MyJava2 65 67 }}} 66 68 67 69 68 * 下載 [ raw-attachment:wiki:Hadoop_Lab4:WordCount2.java WordCount2.java] 並存到/opt/hadoop;[[BR]]Download [raw-attachment:wiki:Hadoop_Lab4:WordCount2.java WordCount2.java] to /opt/hadoop70 * 下載 [http://hadoop.nchc.org.tw/WordCount2.java WordCount2.java] 並存到家目錄;[[BR]]Download [http://hadoop.nchc.org.tw/WordCount2.java WordCount2.java] to home directory 69 71 {{{ 70 ~$ cd /opt/hadoop 71 /opt/hadoop$ wget http://trac.nchc.org.tw/cloud/raw-attachment/wiki/Hadoop_Lab4/WordCount2.java 72 ~$ wget http://hadoop.nchc.org.tw/WordCount2.java 72 73 }}} 73 74 74 75 {{{ 75 $ javac -classpath hadoop- *-core.jar -d MyJava2 WordCount2.java76 $ javac -classpath hadoop-core.jar -d MyJava2 WordCount2.java 76 77 $ jar -cvf wordcount2.jar -C MyJava2 . 77 $ bin/hadoop jar wordcount2.jar WordCount2 lab4_input lab4_out2 -skip pattern.txt78 $ bin/hadoop fs -cat lab4_out2/part-0000078 $ hadoop jar wordcount2.jar WordCount2 lab6_input lab6_out2 -skip pattern.txt 79 $ hadoop fs -cat lab6_out2/part-00000 79 80 }}} 80 81 81 * lab 4_out2 執行結果[[BR]]You should see results like this:82 * lab6_out2 執行結果[[BR]]You should see results like this: 82 83 {{{ 83 84 #!text … … 85 86 Course 2 86 87 I 2 87 NC HC188 NCTU 1 88 89 and 1 89 90 course 1 90 91 enjoy 1 91 92 like 2 92 nc hc193 nctu 1 93 94 this 1 94 95 we 1 … … 97 98 * Let's given case insensitive and ignore pattern for this example 98 99 {{{ 99 /opt/hadoop$ bin/hadoop jar wordcount2.jar WordCount2 -Dwordcount.case.sensitive=false lab4_input lab4_out3 -skip pattern.txt100 /opt/hadoop$ bin/hadoop fs -cat lab4_out3/part-00000100 $ hadoop jar wordcount2.jar WordCount2 -Dwordcount.case.sensitive=false lab6_input lab6_out3 -skip pattern.txt 101 $ hadoop fs -cat lab6_out3/part-00000 101 102 }}} 102 103 103 * lab 4_out3 執行結果[[BR]]You should see results like this:104 * lab6_out3 執行結果[[BR]]You should see results like this: 104 105 {{{ 105 106 #!text … … 110 111 i 2 111 112 like 2 112 nc hc2113 nctu 2 113 114 this 1 114 115 we 1