我使用Cygwin终端在Windows上安装了Apache的Hadoop 2.1版测试版。运行命令hadoop version
会出现此错误:
Error: Could not find or load main class org.apache.hadoop.util.VersionInfo
答案 0 :(得分:10)
您还可以将以下内容添加到〜/ .bashrc
export HADOOP_CLASSPATH=$(cygpath -pw $(hadoop classpath)):$HADOOP_CLASSPATH
这为我解决了
答案 1 :(得分:3)
我尝试在Windows 2008 Server Sp1 64bit上安装Hadoop 2.2.0时遇到了同样的问题。
我安装了cygwin64并配置了openssh。
user2870991的回答对我有用。 修改\ hadoop \ bin \ hadoop脚本,如下所示,注释原始exec行并插入新的exec行。
#exec "$JAVA" $JAVA_HEAP_MAX $HADOOP_OPTS $CLASS "$@"
#add the -claspath "$(cygpath -pw "$CLASSPATH")" TO FIX the script running in cygwin
exec "$JAVA" -classpath "$(cygpath -pw "$CLASSPATH")" $JAVA_HEAP_MAX $HADOOP_OPTS $CLASS "$@"
答案 2 :(得分:2)
在hadoop-config.sh @ line no 285
中添加以下语句CLASSPATH=`cygpath -wp "$CLASSPATH"`
//Comments goes here
if [ "$HADOOP_CLASSPATH" != "" ]; then
# Prefix it if its to be preceded
if [ "$HADOOP_USER_CLASSPATH_FIRST" != "" ]; then
CLASSPATH=${HADOOP_CLASSPATH}:${CLASSPATH}
else
CLASSPATH=${CLASSPATH}:${HADOOP_CLASSPATH}
fi
fi
输出:
admin@admin-PC /cygdrive/e/hadoop/hadoop-2.2.0/bin
$ ./hadoop version
Hadoop 2.2.0
Subversion https://svn.apache.org/repos/asf/hadoop/common -r 1529768
Compiled by hortonmu on 2013-10-07T06:28Z
Compiled with protoc 2.5.0
From source with checksum 79e53ce7994d1628b240f09af91e1af4
This command was run using /E:/hadoop/hadoop-2.2.0/share/hadoop/common/hadoop-common-2.2.0.jar