我尝试运行示例字数程序,我的hdfs文件保存在/input中,输出目录是/output,这是我执行的命令:
[hadoop-2.2.0]$ bin/hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/sources/hadoop-mapreduce-examples-2.2.0-sources.jar org.apache.hadoop.examples.WordCount /input /output
但我收到以下错误:
Exception in thread "main" java.lang.ClassNotFoundException: org.apache.hadoop.examples.WordCount
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at org.apache.hadoop.util.RunJar.main(RunJar.java:205
尝试Hadoop-mapreduce-examples-2.2.0.jar
bin/hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.2.0.jar wordcount /input /output
如果你确实想使用源 jar,你可以先运行下面:
unset HADOOP_CLASSPATH
我认为这是因为
您使用的是源文件。你宁愿执行$HADOOP_HOME/share/hadoop/mapreduce/sources/hadoop-mapreduce-examples-2.2.0.jar相反。也许它会有所帮助。