测试hadoop的 WordCount
1、创建两个文本
[root@bigdata01 /]# mkdir input [root@bigdata01 /]# cd input [root@bigdata01 input]# echo "hello world" >test1.txt [root@bigdata01 input]# echo "hello hadoop" >test2.txt
2、将两个txt文本copy到hadoop下
./代表input目录下所有文本 /input代表hadoop根目录吧 我也不清楚
[root@bigdata01 input]# hadoop fs -put ./ /input
3、查看copy到hadoop的文本
[root@bigdata01 input]# hadoop fs -ls /input Found 2 items -rw-r--r-- 1 root supergroup 12 2017-05-10 04:09 /input/test1.txt -rw-r--r-- 1 root supergroup 13 2017-05-10 04:09 /input/test2.txt
4、查看文本内容
[root@bigdata01 input]# hadoop fs -cat /input/test1.txt hello world
5、运行wordcount的jar包,并输出结果到/output
[root@bigdata01 hadoop-2.7.3]# hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount /input/ /output
6、查看运行结果
[root@bigdata01 hadoop-2.7.3]# hadoop fs -ls /output Found 2 items -rw-r--r-- 1 root supergroup 0 2017-05-10 08:03 /output/_SUCCESS -rw-r--r-- 1 root supergroup 25 2017-05-10 08:03 /output/part-r-00000 [root@bigdata01 hadoop-2.7.3]# hadoop fs -cat /output/part-r-00000 hadoop 1 hello 2 world 1