Hadoop

大数据生态Hadoop(三):官方wordcount示例

2020-03-24  本文已影响0人  HeyJude__

hadoop官方wordcount示例

提供版本JDK1.8+Hadoop2.7.2

在hadoop-2.7.2文件下面创建一个input文件夹

[root@hadoop01 hadoop-2.7.2]$mkdir input

在wcinput文件下创建一个wc.input文件

[root@hadoop01 hadoop-2.7.2]cd input
[root@hadoop01 input]touch wc.input

编辑wc.input文件

[root@hadoop01 input]vim wc.input
# 文件内容
hadoop  
mapreduce   
yarn
yarn    

wc.input文件加载到hdfs

[root@hadoop01 hadoop-2.7.2]hadoop fs -put input/ /tmp/

运行官方jar包

[root@hadoop01 hadoop-2.7.2]hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount /tmp/input/  /tmp/output/

查看wordcount统计词频

[root@hadoop01 hadoop-2.7.2]hadoop fs -cat /tmp/output//part-r-00000
# 统计内容
hadoop  1
mapreduce   1
yarn    2
上一篇 下一篇

猜你喜欢

热点阅读