如何在linux上找到hadoop\u主路径?

qij5mzcb  于 2021-06-04  发布在  Hadoop
关注(0)|答案(2)|浏览(472)

我试图在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/.//*

有人知道吗?

pbpqsu0x

pbpqsu0x1#

hadoop核心jar文件位于${hadoop\u home}/share/hadoop/common目录中,而不是${hadoop\u home}目录中。
可以在.bashrc文件中设置环境变量。

vim ~/.bashrc

然后将以下行添加到.bashrc文件的末尾。

export HADOOP_HOME=/your/hadoop/installation/directory

只需将路径替换为hadoop安装路径。

yvt65v4c

yvt65v4c2#

导航到安装hadoop的路径。定位 ${HADOOP_HOME}/etc/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
    export HADOOP_CLASSPATH=${HADOOP_CLASSPATH+$HADOOP_CLASSPATH:}$f
done

希望这有帮助!

相关问题