hadoop 部署后测试 运行wordcount

由于hbase集群部署失败,所以我想测试一下自己的 hadoop 是否安装成功

1.  hadoop fs -mkdir /input

在HDFS中创建input文件目录


[plain] view plain copy
  1. [[email protected] hadoop]# hadoop fs -mkdir /input  


hadoop fs -put LICENSE.txt  /input

我当前在hadoop的目录下,有个LICENSE.txt的文件,把它放到hdfs的input目录下面


[plain] view plain copy
  1. [[email protected] hadoop]# hadoop fs -put LICENSE.txt  /input   

3

hadoop fs -ls /input

查看文件是否正确传入到/input目录下

或者 hadoop fs -cat /input/LICENSE.txt查看文件内容


[plain] view plain copy
  1. [[email protected] hadoop]# hadoop fs -ls /input  
  2. Found 1 items  
  3. -rw-r--r--   2 root supergroup      84854 2018-06-19 09:34 /input/LICENSE.txt  
  4. [[email protected] hadoop]# hadoop fs -cat /input LICENSE.txt   

4  

执行:hadoop jar hadoop-mapreduce-examples-2.7.3.jar wordcount /input /output

或者绝对路径:

hadoop jar /usr/hadoop/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.1.jar wordcount /input /output


[plain] view plain copy
  1. [[email protected] hadoop]# hadoop jar /usr/hadoop/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar   
  2.    wordcount /input /output  

6  看到这个就成功了


hadoop 部署后测试 运行wordcount



 


7 hadoop fs -ls /output

查看输出结果的目录

hadoop fs -cat /output/part-r-00000

查看输出结果

结果就是对LICENSE.txt文件中单词进行计数统计了,到这就运行完成了。

[plain] view plain copy
  1. [[email protected] hadoop]# hadoop fs -ls /output  
  2. Found 2 items  
  3. -rw-r--r--   2 root supergroup          0 2018-06-19 09:47 /output/_SUCCESS  
  4. -rw-r--r--   2 root supergroup      22002 2018-06-19 09:47 /output/part-r-00000  


hadoop 部署后测试 运行wordcount