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
原文地址:https://www.cnblogs.com/413xiaol/p/9961028.html