http://hadoop.apache.org/mapreduce/docs/r0.21.0/mapred_tutorial.html经验总结:
1)必须将相关的Class文件(包括Map,Reduce)打包成Jar文件
2)export HADOOP_CLASSPATH=./
3) 不要将Jar文件和Class文件混淆在一起,放在一个目录, 例如目录结构如下:
否则执行 hadoop jar test.jar NewMaxTemperature /input /output 的时候, 会出现 下面的错误,
参考:
http://groups.google.com/group/hadoopors/browse_thread/thread/b011ef93af5633ae/8227267657518bbb?#8227267657518bbb 2011-10-22 22:44:12,062 INFO org.apache.hadoop.mapred.TaskInProgress: Error from attempt_201110222208_0014_m_000001_3 on tracker_ad:localhost/127.0.0.1:2401: java.lang.RuntimeException: java.lang.ClassNotFoundException: NewMaxTemperature$NewMaxTemperatureMapper
at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:1128)
at org.apache.hadoop.mapreduce.task.JobContextImpl.getMapperClass(JobContextImpl.java:167)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:612)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:328)
at org.apache.hadoop.mapred.Child$4.run(Child.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:742)