我正在尝试在hadoop服务器上运行以下java代码。
javac -classpath ${HADOOP_HOME}/hadoop-${HADOOP_VERSION}-core.jar -d wordcount_classes WordCount.java
但我无法找到{HADOOP_HOME}
。我尝试使用hadoop -classpath
,但它输出如下:
/etc/hadoop/conf:/usr/lib/hadoop/lib/*:/usr/lib/hadoop/.//*:/usr/lib/hadoop-hdfs/./:/usr/lib/hadoop-hdfs/lib/*:/usr/lib/hadoop-hdfs/.//*:/usr/lib/hadoop-yarn/.//*:/usr/lib/hadoop-0.20-mapreduce/./:/usr/lib/hadoop-0.20-mapreduce/lib/*:/usr/lib/hadoop-0.20-mapreduce/.//*
有人对此有任何想法吗?
答案 0 :(得分:4)
hadoop-core jar文件位于$ {HADOOP_HOME} / share / hadoop / common目录中,而不在$ {HADOOP_HOME}目录中。
您可以在.bashrc文件中设置环境变量。
vim ~/.bashrc
然后将以下行添加到.bashrc文件的末尾。
export HADOOP_HOME=/your/hadoop/installation/directory
只需用hadoop安装路径替换路径。
答案 1 :(得分:4)
导航到安装hadoop的路径并更改目录,如下所示
/usr/lib/hadoop-2.2.0/etc/hadoop
当您输入ls命令时,您应该看到所有这些文件。
capacity-scheduler.xml httpfs-site.xml
configuration.xsl log4j.properties
container-executor.cfg mapred-env.cmd
core-site.xml mapred-env.sh
core-site.xml~ mapred-queues.xml.template
hadoop-env.cmd mapred-site.xml
hadoop-env.sh mapred-site.xml~
hadoop-env.sh~ mapred-site.xml.template
hadoop-metrics2.properties slaves
hadoop-metrics.properties ssl-client.xml.example
hadoop-policy.xml ssl-server.xml.example
hdfs-site.xml yarn-env.cmd
hdfs-site.xml~ yarn-env.sh
httpfs-env.sh yarn-site.xml
httpfs-log4j.properties yarn-site.xml~
httpfs-signature.secret
核心配置设置在hadoop-env.sh中可用。
您可以在此文件中看到类路径设置,我在此处复制了一些示例供您参考。
# The java implementation to use.
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_67
# The jsvc implementation to use. Jsvc is required to run secure datanodes.
#export JSVC_HOME=${JSVC_HOME}
export HADOOP_CONF_DIR=${HADOOP_CONF_DIR}
# Extra Java CLASSPATH elements. Automatically insert capacity-scheduler.
for f in $HADOOP_HOME/contrib/capacity-scheduler/*.jar; do
if [ "$HADOOP_CLASSPATH" ]; then
export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$f
else
export HADOOP_CLASSPATH=$f
fi
done
希望这有帮助!