运行mapreduce

it2024-04-22  347

运行mapreducemap 映射reduce 规约

[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hadoop jar ./share/hadoop/mapreduce2/hadoop-mapreduce-examples-2.6.0-cdh5.7.0.jar pi 5 10

词频统计[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ vi a.logruozejepsonwww.ruozedata.comdashuadaifanren1abca b c ruoze jepon[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ vi b.txta b d e f ruoze1 1 3 5[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hdfs dfs -mkdir /wordcount[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hdfs dfs -mkdir /wordcount/input

[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hdfs dfs -put a.log /wordcount/input[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hdfs dfs -put b.txt /wordcount/input[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hdfs dfs -ls /wordcount/input/Found 2 items-rw-r--r-- 1 hadoop supergroup 76 2019-02-16 21:59 /wordcount/input/a.log-rw-r--r-- 1 hadoop supergroup 24 2019-02-16 21:59 /wordcount/input/b.txt[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$

[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hadoop jar \./share/hadoop/mapreduce2/hadoop-mapreduce-examples-2.6.0-cdh5.7.0.jar \wordcount /wordcount/input /wordcount/output1

[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hdfs dfs -cat /wordcount/output1/part-r-0000019/02/16 22:05:46 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable1 33 15 1a 3adai 1b 3c 2d 1dashu 1e 1f 1fanren 1jepon 1jepson 1ruoze 3www.ruozedata.com 1[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hdfs dfs -get /wordcount/output1/part-r-00000 ./[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ cat part-r-000001 33 15 1a 3adai 1b 3c 2d 1dashu 1e 1f 1fanren 1jepon 1jepson 1ruoze 3www.ruozedata.com 1[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$

 

把每个单词出现的次数统计出来

 

转载于:https://www.cnblogs.com/xuziyu/p/10403929.html

最新回复(0)