Changes between Initial Version and Version 1 of III110813/Lab6


Ignore:
Timestamp:
Oct 21, 2011, 2:31:08 PM (13 years ago)
Author:
jazz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • III110813/Lab6

    v1 v1  
     1◢ <[wiki:III110813/Lab5 實作五]> | <[wiki:III110813 回課程大綱]> ▲ | <[wiki:III110813/Lab7 實作七]> ◣
     2
     3= 實作六 Lab 6 =
     4
     5[[PageOutline]]
     6
     7{{{
     8#!html
     9<div style="text-align: center;"><big style="font-weight: bold;"><big>執行 MapReduce 基本運算<br/>Running MapReduce by Examples</big></big></div>
     10}}}
     11
     12= Sample 1 : WordCount =
     13 
     14 * 如名稱,WordCount會對所有的字作字數統計,並且從a-z作排列[[BR]]WordCount example will count each word shown in documents and sorting from a to z.
     15{{{
     16~$ hadoop jar hadoop-examples.jar wordcount lab5_input lab5_out2
     17}}}
     18 * 檢查輸出結果的方法同之前方法[[BR]]Let's check the computed result of '''wordcount''' from HDFS :
     19{{{
     20$ hadoop fs -ls lab5_out2
     21$ hadoop fs -cat lab5_out2/part-r-00000
     22}}}
     23 * 結果如下[[BR]]You should see results like this:
     24{{{
     25"".     4
     26"*"     9
     27"127.0.0.1"     3
     28"AS     2
     29"License");     2
     30"_logs/history/"        1
     31"alice,bob      9
     32
     33( ... skip ... )
     34}}}
     35
     36= Sample 2: grep = 
     37 
     38 * grep 這個命令是擷取文件裡面特定的字元,在Hadoop example中此指令可以擷取文件中有此指定文字的字串,並作計數統計[[BR]]grep is a command to extract specific characters in documents. In hadoop examples, you can use this command to extract strings match the regular expression and count for matched strings.
     39{{{
     40$ hadoop fs -put /etc/hadoop/conf lab5_input
     41$ hadoop fs -ls lab5_input
     42$ hadoop jar hadoop-examples.jar grep lab5_input lab5_out3 'dfs[a-z.]+'
     43}}}
     44 * 運作的畫面如下:[[BR]]You should see procedure like this: 
     45{{{
     4611/04/19 10:00:20 INFO mapred.FileInputFormat: Total input paths to process : 25
     4711/04/19 10:00:20 INFO mapred.JobClient: Running job: job_201104120101_0645
     4811/04/19 10:00:21 INFO mapred.JobClient:  map 0% reduce 0%
     49( ... skip ... )
     50}}}
     51 * 接著查看結果[[BR]]Let's check the computed result of '''grep''' from HDFS :
     52{{{
     53$ hadoop fs -ls lab5_out3
     54Found 2 items
     55drwx------   - hXXXX supergroup          0 2011-04-19 10:00 /user/hXXXX/lab5_out1/_logs
     56-rw-r--r--   2 hXXXX supergroup       1146 2011-04-19 10:00 /user/hXXXX/lab5_out1/part-00000
     57$ hadoop fs -cat lab5_out1/part-00000
     58}}}
     59 * 結果如下[[BR]]You should see results like this:
     60{{{
     614       dfs.permissions
     624       dfs.replication
     634       dfs.name.dir
     643       dfs.namenode.decommission.interval.
     653       dfs.namenode.decommission.nodes.per.interval
     663       dfs.
     67( ... skip ... )
     68}}}
     69
     70= More Examples =
     71 
     72 可執行的指令一覽表:[[BR]]Here is a list of hadoop examples :
     73
     74 || aggregatewordcount ||  An Aggregate based map/reduce program that counts the words in the input files. ||
     75 || aggregatewordhist || An Aggregate based map/reduce program that computes the histogram of the words in the input files. ||
     76 || grep ||  A map/reduce program that counts the matches of a regex in the input. ||
     77 || join || A job that effects a join over sorted, equally partitioned datasets ||
     78 || multifilewc ||  A job that counts words from several files. ||
     79 || pentomino  || A map/reduce tile laying program to find solutions to pentomino problems. ||
     80 || pi ||  A map/reduce program that estimates Pi using monte-carlo method. ||
     81 || randomtextwriter ||  A map/reduce program that writes 10GB of random textual data per node. ||
     82 || randomwriter || A map/reduce program that writes 10GB of random data per node. ||
     83 || sleep ||  A job that sleeps at each map and reduce task. ||
     84 || sort || A map/reduce program that sorts the data written by the random writer. ||
     85 || sudoku ||  A sudoku solver. ||
     86 || wordcount || A map/reduce program that counts the words in the input files. ||
     87
     88You could find more detail at [http://hadoop.apache.org/core/docs/current/api/org/apache/hadoop/examples/package-summary.html org.apache.hadoop.examples]