Changes between Initial Version and Version 1 of YMU110509/Lab4


Ignore:
Timestamp:
May 9, 2011, 11:26:59 AM (14 years ago)
Author:
jazz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • YMU110509/Lab4

    v1 v1  
     1[[PageOutline]]
     2
     3◢ <[wiki:YMU110509/Lab3 實作三]> | <[wiki:YMU110509 回課程大綱]> ▲ | <[wiki:YMU110509/Lab5 實作五]> ◣
     4
     5= 實作四 =
     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: grep = 
     13 
     14 * 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.
     15 
     16{{{
     17$ hadoop fs -put /etc/hadoop/conf lab5_input
     18$ hadoop fs -ls lab5_input
     19$ hadoop jar hadoop-examples.jar grep lab5_input lab5_out1 'dfs[a-z.]+'
     20 
     21}}}
     22 
     23 運作的畫面如下:[[BR]]You should see procedure like this:
     24 
     25{{{
     2611/04/19 10:00:20 INFO mapred.FileInputFormat: Total input paths to process : 25
     2711/04/19 10:00:20 INFO mapred.JobClient: Running job: job_201104120101_0645
     2811/04/19 10:00:21 INFO mapred.JobClient:  map 0% reduce 0%
     29( ... skip ... )
     30}}}
     31
     32 
     33 * 接著查看結果[[BR]]Let's check the computed result of '''grep''' from HDFS :
     34
     35{{{
     36$ hadoop fs -ls lab5_out1
     37Found 2 items
     38drwx------   - hXXXX supergroup          0 2011-04-19 10:00 /user/hXXXX/lab5_out1/_logs
     39-rw-r--r--   2 hXXXX supergroup       1146 2011-04-19 10:00 /user/hXXXX/lab5_out1/part-00000
     40$ hadoop fs -cat lab5_out1/part-00000
     41}}}
     42
     43 結果如下[[BR]]You should see results like this:
     44
     45{{{
     464       dfs.permissions
     474       dfs.replication
     484       dfs.name.dir
     493       dfs.namenode.decommission.interval.
     503       dfs.namenode.decommission.nodes.per.interval
     513       dfs.
     52( ... skip ... )
     53}}}
     54
     55= Sample 2 : WordCount =
     56 
     57 * 如名稱,WordCount會對所有的字作字數統計,並且從a-z作排列[[BR]]WordCount example will count each word shown in documents and sorting from a to z.
     58 
     59{{{
     60~$ hadoop jar hadoop-examples.jar wordcount lab5_input lab5_out2
     61}}}
     62 
     63 檢查輸出結果的方法同之前方法[[BR]]Let's check the computed result of '''wordcount''' from HDFS :
     64
     65{{{
     66$ hadoop fs -ls lab5_out2
     67$ hadoop fs -cat lab5_out2/part-r-00000
     68}}}
     69
     70 結果如下[[BR]]You should see results like this:
     71
     72{{{
     73"".     4
     74"*"     9
     75"127.0.0.1"     3
     76"AS     2
     77"License");     2
     78"_logs/history/"        1
     79"alice,bob      9
     80
     81( ... skip ... )
     82}}}
     83
     84= More Examples =
     85 
     86 可執行的指令一覽表:[[BR]]Here is a list of hadoop examples :
     87
     88 || aggregatewordcount ||  An Aggregate based map/reduce program that counts the words in the input files. ||
     89 || aggregatewordhist || An Aggregate based map/reduce program that computes the histogram of the words in the input files. ||
     90 || grep ||  A map/reduce program that counts the matches of a regex in the input. ||
     91 || join || A job that effects a join over sorted, equally partitioned datasets ||
     92 || multifilewc ||  A job that counts words from several files. ||
     93 || pentomino  || A map/reduce tile laying program to find solutions to pentomino problems. ||
     94 || pi ||  A map/reduce program that estimates Pi using monte-carlo method. ||
     95 || randomtextwriter ||  A map/reduce program that writes 10GB of random textual data per node. ||
     96 || randomwriter || A map/reduce program that writes 10GB of random data per node. ||
     97 || sleep ||  A job that sleeps at each map and reduce task. ||
     98 || sort || A map/reduce program that sorts the data written by the random writer. ||
     99 || sudoku ||  A sudoku solver. ||
     100 || wordcount || A map/reduce program that counts the words in the input files. ||
     101
     102You could find more detail at [http://hadoop.apache.org/core/docs/current/api/org/apache/hadoop/examples/package-summary.html org.apache.hadoop.examples]