Changes between Version 1 and Version 2 of waue/2011/0426_1


Ignore:
Timestamp:
Apr 25, 2011, 10:11:09 PM (14 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/2011/0426_1

    v1 v2  
    1616 * 範例一:使用 cat 當 mapper,使用 wc 當 reducer
    1717{{{
    18 hadoop@lucid:~$ cd /opt/hadoop
    19 hadoop@lucid:/opt/hadoop$ bin/start-all.sh
    20 hadoop@lucid:/opt/hadoop$ bin/hadoop fs -put conf input
    21 hadoop@lucid:/opt/hadoop$ bin/hadoop jar ./contrib/streaming/hadoop-0.20.2-streaming.jar -input input -output output -mapper /bin/cat -reducer /usr/bin/wc
     18$ cd /opt/hadoop
     19$ bin/start-all.sh
     20$ bin/hadoop fs -put conf input
     21$ bin/hadoop jar ./contrib/streaming/hadoop-0.20.2-streaming.jar -input input -output output -mapper /bin/cat -reducer /usr/bin/wc
    2222}}}
    2323 * 範例二:使用 Bash Shell Script 當 Mapper 與 Reducer
    2424{{{
    25 hadoop@lucid:/opt/hadoop$ echo "sed -e \"s/ /\n/g\" | grep ." > streamingMapper.sh
    26 hadoop@lucid:/opt/hadoop$ echo "uniq -c | awk '{print \$2 \"\t\" \$1}'" > streamingReducer.sh
    27 hadoop@lucid:/opt/hadoop$ chmod a+x streamingMapper.sh
    28 hadoop@lucid:/opt/hadoop$ chmod a+x streamingReducer.sh
    29 hadoop@lucid:/opt/hadoop$ bin/hadoop fs -rmr input output
    30 hadoop@lucid:/opt/hadoop$ bin/hadoop fs -put conf input
    31 hadoop@lucid:/opt/hadoop$ bin/hadoop jar ./contrib/streaming/hadoop-0.20.2-streaming.jar -input input -output output -mapper streamingMapper.sh -reducer streamingReducer.sh -file streamingMapper.sh -file streamingReducer.sh
     25$ echo "sed -e \"s/ /\n/g\" | grep ." > streamingMapper.sh
     26$ echo "uniq -c | awk '{print \$2 \"\t\" \$1}'" > streamingReducer.sh
     27$ chmod 755 streaming*.sh
     28$ bin/hadoop fs -rmr input output
     29$ bin/hadoop fs -put conf input
     30$ bin/hadoop jar ./contrib/streaming/hadoop-0.20.2-streaming.jar -input input -output output -mapper streamingMapper.sh -reducer streamingReducer.sh -file streamingMapper.sh -file streamingReducer.sh
    3231}}}