MapReduce执行jar练习

 

一、用程序生成输入文件1.txt和2.txthtml

生成程序源码以下:oop

http://www.javashuo.com/article/p-dnacfxjf-mk.htmlspa

 

2.  上传文件到hdfs文件系统3d

建立输入文件目录code

hdfs dfs -mkdir -p /hadoop/inputhtm

 

上传文件到输入目录blog

hdfs dfs -put 1.txt /hadoop/input/hadoop

hdfs dfs -put 2.txt /hadoop/input/get

 

以下图:input

 

 

3.  打包并上传MapReduce程序jar

源码以下:

http://www.javashuo.com/article/p-uwqbabwa-mm.html

 

打包为hadoop.jar并上传到集群上,执行命令

hadoop jar hadoop.jar /hadoop/input/ /hadoop/output

 

以下图:

 

 

 

查看输出结果,以下图:

 

 

查看输出内容:

hdfs dfs -cat /hadoop/output/part-r-00000

 输出结果以下:

2000    9997
2001    9993
2002    9997
2003    9994
2004    9995
2005    9983
2006    9978
2007    9990
2008    9968
2009    9987
2010    9996
2011    9986
2012    9997
2013    9987
2014    9999
2015    9997
2016    9995
2017    9998

 

输出结果正确!

 

 

 

 

.

相关文章
相关标签/搜索