运行hadoop自带的wordcount例子程序
Posted 413Xiaol
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了运行hadoop自带的wordcount例子程序相关的知识,希望对你有一定的参考价值。
1.准备文件
[[email protected] ~]# cat input.txt
hello java
hello python
hello c
hello java
hello js
hello html
hello java
[[email protected] ~]# hadoop fs -mkdir /input
[[email protected] ~]# hadoop fs -put input.txt /input
[[email protected] ~]# hadoop fs -ls /input
Found 1 items
-rw-r--r-- 2 root supergroup 74 2018-11-14 21:42 /input/input.txt
2.例子程序位置
/usr/local/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar
3.运行
[[email protected] ~]# hadoop jar hadoop-mapreduce-examples-2.7.3.jar wordcount /input/input.txt /output
[[email protected] ~]# hadoop fs -ls /output/
Found 2 items
-rw-r--r-- 2 root supergroup 0 2018-11-14 21:46 /output/_SUCCESS
-rw-r--r-- 2 root supergroup 40 2018-11-14 21:46 /output/part-r-00000
4.查看结果
[[email protected] ~]# hadoop fs -text /output/part-r-00000
c 1
hello 7
html 1
java 3
js 1
python 1
以上是关于运行hadoop自带的wordcount例子程序的主要内容,如果未能解决你的问题,请参考以下文章