如何在eclipse调试mapreduce程序
如何在eclipse或myeclipse调试mapreduce程序,这个可能是初学mr程序者碰到的一个难题
在hadoop1.2.1后,在下载的源代码中找不到hadoop-eclipse-plugin相关的jar或源代码。
其实hadoop目前使用maven进行源代码的管理与调试,可以参考文献:
http://blog.cloudera.com/blog/2012/08/developing-cdh-applications-with-maven-and-eclipse/
A sample POM for setting up a basic Maven project for CDH application development
https://gist.github.com/jnatkins/3517129
注意:CDH是hadoop的封装版本,很稳定,并且更新也很快。
如果需要在eclipse下编写MR程序并进行调试,需要以下前提条件:
1:安装maven,建议安装maven3.0.4或上以版本
2:使用eclipse较新的版本,如Kepler Service Release 1
3:在eclipse上安装m2eclipse插件进行maven项目的管理
4:创建maven项目,并将pom.xml替换为https://gist.github.com/jnatkins/3517129项目中的pom.xml或下面的pom.xml(本人使用的,可以开发MR程序,操作HDFS等)
5:如果出现权限问题(如在windows下调试),可以将Administrator的用户名修改为hdfs即可。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.cdh</groupId> <artifactId>cdh-test</artifactId> <version>SNAPSHOT-1.0.0</version> <packaging>jar</packaging> <name>cdh-test</name> <url>http://maven.apache.org</url> <properties> <hadoop.version>2.0.0-mr1-cdh4.4.0</hadoop.version> <hbase.version>0.94.6-cdh4.4.0</hbase.version> <project.build.sourceEncoding>utf-8</project.build.sourceEncoding> <maven.compiler.encoding>utf-8</maven.compiler.encoding> </properties> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <encoding>utf-8</encoding> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.9</version> <configuration> <buildOutputDirectory>eclipse-classes</buildOutputDirectory> <downloadSources>true</downloadSources> <downloadJavadocs>false</downloadJavadocs> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> <version>${hadoop.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-mapreduce-client-core</artifactId> <version>2.0.0-cdh4.4.0</version> <exclusions> <exclusion> <artifactId> jersey-test-framework-grizzly2 </artifactId> <groupId> com.sun.jersey.jersey-test-framework </groupId> </exclusion> <exclusion> <artifactId>netty</artifactId> <groupId>org.jboss.netty</groupId> </exclusion> </exclusions> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.hbase</groupId> <artifactId>hbase</artifactId> <version>${hbase.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.hadoop.gplcompression</groupId> <artifactId>hadoop-lzo-cdh4</artifactId> <version>0.4.15-gplextras</version> </dependency> <dependency> <groupId>commons-httpclient</groupId> <artifactId>commons-httpclient</artifactId> <version>3.1</version> </dependency> <dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>2.2.9</version> </dependency> </dependencies> <repositories> <repository> <id>cloudera</id> <url>https://repository.cloudera.com/artifactory/cloudera-repos</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> </project>

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
Storm Topology及分组原理
Storm的通信机制,需要满足如下一些条件以满足Storm的语义。 1、建立数据传输的缓冲区。在通信连接没有建立之前把发送的数据缓存起来。数据发送方可以在连接建立之前发送消息,而不需要等连接建立起来,可是的接收方是独立运行的。 2、在消息传输层保证消息最多只能发送一次,Storm系统有ACK机制,是的没有被发送成功的消息会被重发,若消息层面也重发,会导致消息发送多次。 这种消息机制由两个接口来定义,backtype.storm.messaging.IContext和backtype.storm.messaging.IConnection. IContext负责客户端和服务器端建立的连接,主要有四个方法。 1、prepare(Map stormConf):总从Storm定义的prepare方法,可以接收storm的配置。 2、term():终止,方法会在worker卸载这个传输插件的时候调用,自定义实现时可以在这里释放占用的资源。 3、bind(String topologyId,int port):建立服务器端的连接。 4、connect(String stormId,String h...
- 下一篇
MapReduce的数据流程、执行流程
MapReduce的数据流程: 预先加载本地的输入文件 经过MAP处理产生中间结果 经过shuffle程序将相同key的中间结果分发到同一节点上处理 Recude处理产生结果输出 将结果输出保存在hdfs上 MAP 在map阶段,使用job.setInputFormatClass定义的InputFormat将输入的数据集分割成小数据块splites, 同时InputFormat提供一个RecordReder的实现。默认的是TextInputFormat, 他提供的RecordReder会将文本的一行的偏移量作为key,这一行的文本作为value。 这就是自定义Map的输入是<LongWritable, Text>的原因。 然后调用自定义Map的map方法,将一个个<LongWritable, Text>对输入给Map的map方法。 最终是按照自定义的MAP的输出key类,输出class类生成一个List<MapOutputKeyClass, MapOutputValueClass>。 Partitioner 在map阶段的最后,会先调用job.set...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- CentOS7编译安装Gcc9.2.0,解决mysql等软件编译问题
- Jdk安装(Linux,MacOS,Windows),包含三大操作系统的最全安装
- SpringBoot2配置默认Tomcat设置,开启更多高级功能
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- SpringBoot2全家桶,快速入门学习开发网站教程
- Springboot2将连接池hikari替换为druid,体验最强大的数据库连接池
- SpringBoot2整合Thymeleaf,官方推荐html解决方案
- 设置Eclipse缩进为4个空格,增强代码规范
- MySQL8.0.19开启GTID主从同步CentOS8
- SpringBoot2编写第一个Controller,响应你的http请求并返回结果