2013-11-27 72 views
0

我在MacOS開發環境中使用Apache Hadoop 2.2.0。當試圖在Apache的文檔中描述執行Hadoop minicluster:啓動hadoop 2.2.0 minicluster時出錯:java.lang.NoClassDefFoundError:org/apache/hadoop/yarn/server/MiniYARNCluster

hadoop jar ./share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.2.0-tests.jar minicluster 

,我發現了錯誤

java.lang.NoClassDefFoundError: org/apache/hadoop/yarn/server/MiniYARNCluster at org.apache.hadoop.mapreduce.MiniHadoopClusterManager.start(MiniHadoopClusterManager.java:170) at org.apache.hadoop.mapreduce.MiniHadoopClusterManager.run(MiniHadoopClusterManager.java:129) at . . . . . . .

任何想法如何解決這個問題?

回答

8

看起來像我找到了解決方案:默認情況下,包含MiniYARNCluster的jar文件不是Hadoop類路徑的一部分,它必須顯式添加到HADOOP_CLASSPATH中。下面的代碼片段工作得很好:

export HADOOP_CLASSPATH=./share/hadoop/yarn/test/hadoop-yarn-server-tests-2.2.0-tests.jar 
./bin/hadoop jar ./share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.2.0-tests.jar minicluster