本地测试MapReduce程序

IDE工具: eclipse

设置本地(windows)调试MapReduce程序:

1. 编写Mapper类、Reducer类、编写Main类

可参考 https://blog.csdn.net/qq_42881421/article/details/83353640

2.准备本地的输入文件

本地测试MapReduce程序_第1张图片

in里面有文本文件a.txt

本地测试MapReduce程序_第2张图片

a.txt内容如下:

hello world
hello hadoop
hello wordcount

 

3. 设置本地参数:

右键Main类-->Run As-->Run Configurations

 本地测试MapReduce程序_第3张图片

 

 

点击Arguments,在Program arguments设置输入输出参数:

file:///E:/test/wordcount/in file:///E:/test/wordcount/out

 

 

本地测试MapReduce程序_第4张图片

注意:

1.输入路径和输出路径之间用空格隔开(或者用换行隔开)

2.输出文件夹不能存在,执行MapReduce程序会自动创建

3.根据实际情况修改路径

 

点击上图的Run运行

上图箭头指的框框由红色变为灰色后,表示程序运行完成

查看输出,自动生成了输出目录

本地测试MapReduce程序_第5张图片

out目录下的文件有

本地测试MapReduce程序_第6张图片

查看part-r-00000

本地测试MapReduce程序_第7张图片

 

本地代码编写,本地运行测试,极大的方便了程序的调试,待程序调试OK后,再打jar包上传到集群中运行。

 

 

完成! enjoy it!

 

你可能感兴趣的:(Hadoop,hadoop,mapreduce,本地调试)