运行“hadoop version”命令时,cygwin上hadoop中的类路径问题

41zrol4v  于 2021-06-03  发布在  Hadoop
关注(0)|答案(3)|浏览(473)

我已经使用cygwin终端在windows上安装了来自apache的hadoopversion2.1beta。运行命令 hadoop version 告诉我这个错误:

Error: Could not find or load main class org.apache.hadoop.util.VersionInfo
vddsk6oq

vddsk6oq1#

在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
eqqqjvef

eqqqjvef2#

您还可以将以下内容添加到~/.bashrc

export HADOOP_CLASSPATH=$(cygpath -pw $(hadoop classpath)):$HADOOP_CLASSPATH

这帮我解决了

b4lqfgs4

b4lqfgs43#

我在Windows2008ServerSP164bit上安装Hadoop2.2.0时遇到了同样的问题。
我已经安装了cygwin64并配置了openssh。
用户2870991的答案对我很有用。修改\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 "$@"

相关问题