如何在eclipse或myeclipse調試mapreduce程序,這個多是初學mr程序者碰到的一個難題 git
在hadoop1.2.1後,在下載的源代碼中找不到hadoop-eclipse-plugin相關的jar或源代碼。 github
其實hadoop目前使用maven進行源代碼的管理與調試,能夠參考文獻: sql
http://blog.cloudera.com/blog/2012/08/developing-cdh-applications-with-maven-and-eclipse/ apache
A sample POM for setting up a basic Maven project for CDH application development windows
https://gist.github.com/jnatkins/3517129 app
注意:CDH是hadoop的封裝版本,很穩定,而且更新也很快。 eclipse
若是須要在eclipse下編寫MR程序並進行調試,須要如下前提條件: maven
1:安裝maven,建議安裝maven3.0.4或上以版本 ide
2:使用eclipse較新的版本,如Kepler Service Release 1 oop
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>