WordCount案例。
创建文件目录
1
# bin/hdfs dfs -mkdir /test/input/
创建并编写input文件
1
2
3# touch wc.input
# vim wc.input
写若干个单词,用回车或空格分开将input文件放入input目录
1
# bin/hdfs dfs -put ./wc.input /test/input/
查看文件内容
1
# bin/hdfs dfs -text /test/input/wc.input
运行WordCount案例
1
# bin/yarn jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.8.0.jar wordcount /test/input/wc.input /test/output
查看结果
1
2
3
4
5
6
7
8
9
10
11
12# bin/hdfs dfs -ls /test/output
ound 2 items
-rw-r--r-- 1 root supergroup 0 2017-04-07 06:17 /test/output/_SUCCESS
-rw-r--r-- 1 root supergroup 50 2017-04-07 06:17 /test/output/part-r-00000
# bin/hdfs dfs -text /test/output/part-r-00000
hadoop 4
hdfs 2
hello 1
mapreduce 1
wor1 1
yarn 2