I am able to debug MapReduce (of Hadoop 1.2.1) in Eclipse by following the steps in http://www.thecloudavenue.com/2012/10/debugging-hadoop-mapreduce-program-in.html. But how do I debug MapReduce (of Hadoop 2.2 or higher) in Eclipse?
相关问题
- Pass custom debug information to Microsoft bot fra
- Eclipse and Mylyn : how to disable grey files in t
- Spark on Yarn Container Failure
- Installing Pydev for Eclipse throws error
- Error in Scala Compiler: java.lang.AssertionError:
You can debug in same way. You just run you MapReduce code in standalone mode and use eclipse to debug MR code like any Java code.
Here are the steps I setup in Eclipse. Environment: Ubuntu 16.04.2, Eclipse Neon.3 Release (4.6.3RC2), jdk1.8.0_121. I did a fresh hadoop-2.7.3 installation under /j01/srv/hadoop, which is my $HADOOP_HOME. Replace $HADOOP_HOME value with your actual path wherever referenced below. For hadoop running from Eclipse, you do not need to do any hadoop configurations, what really needed is to pull the right set of hadoop jars into Eclipse.
Step 1 Create new Java Project
File > New > Project...
Select Java Project, Next
Enter Project name: hadoopmr
Click Configure default...
Source folder name: src/main/java
Output folder name: target/classes
Click Apply, OK, then Next
Click tab Libraries
Click Add External JARs...
Browse to hadoop installation folder, and add the following jars, when done click Finish
Step 2 Create a MapReduce example
Create a new package: org.apache.hadoop.examples
Create WordCount.java under package org.apache.hadoop.examples with the following contents:
Create input.txt under /home/hadoop/input/ (or your path) with the following contents:
Step 3 Setup Debug Configuration
In Eclipse, open WordCount.java, set breakpoints in places you like.
Right click on WordCount.java, Debug As > Debug Configurations...
Select Java Application, click New launch configuration on top-left icon
Enter org.apache.hadoop.examples.WordCount in Main class box
Click Arguments tab
enter
into Program arguments
Click Apply, then Debug
Program starts along with hadoop, it should hit the breakpoints you set.
Check results at
Notes:
1) If program does not run, make sure Project > Build Automatically is checked.
Project > Clean… to force a build
2) You can get more examples from
Copy them into this project to continue explore
3) You can download this eclipse project from
In Eclipse, File > Import... > Existing Projects into Workspace > Next
Browse to cloned project and import it
Open .classpath, replace /j01/srv/hadoop-2.7.3 with your hadoop installation home