上一节我们已经在ubuntu中安装好了hadoop集群,这一篇就在搭建好的hadoop中运行一个国际惯例wordcount程序,
一是可以验证我们hadoop集群是否真的搭建成功
二是顺便熟悉一下hadoop程序的运行流程
1.在本地 创建一个wordcount文件
root@master:~# vim wordcount.txt
root@master:~# cat wordcount.txt
hello world
hello
2.将这个文件上传到hdfs中
root@master:~# hadoop dfs -put ./wordcount.txt /firstTestDir
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.
root@master:~# hadoop dfs -ls /
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.
Found 2 items
drwxr-xr-x - root supergroup 0 2018-05-14 10:03 /firstTestDir
drwx------ - root supergroup 0 2018-05-14 09:42 /tmp
root@master:~# hadoop dfs -ls /firstTestDir
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.
Found 2 items
-rw-r--r-- 1 root supergroup 22002 2018-05-13 21:14 /firstTestDir/a.txt
-rw-r--r-- 1 root supergroup 19 2018-05-14 10:03 /firstTestDir/wordcount.txt
3.运行wordcount
3.1 hadoop中已经为我们提供了一些example案例在/hadoop-2.6.5/share/hadoop/mapreduce下
root@mas