1.准备文件
[root@master ~]# cat input.txt
hello java
hello python
hello c
hello java
hello js
hello html
hello java
[root@master ~]# hadoop fs -mkdir /input
[root@master ~]# hadoop fs -put input.txt /input
[root@master ~]# 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.运行
[root@master ~]# hadoop jar hadoop-mapreduce-examples-2.7.3.jar wordcount /input/input.txt /output
[root@master ~]# 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.查看结果
[root@master ~]# hadoop fs -text /output/part-r-00000
c 1
hello 7
html 1
java 3
js 1
python 1