$HADOOP_HOME/bin/hadoop文件是Hadoop主要shell脚本,它提供格式化HDFS、恢复namenode、HDFS Shell、任务提交等诸多功能,它的执行语句在最后一行,如下:
exec "$JAVA" $JAVA_HEAP_MAX $HADOOP_OPTS -classpath "$CLASSPATH" $CLASS "$@"
下面是这几个变量的说明:
- $JAVA
$JAVA_HOME/bin/java
- $JAVA_HEAP_MAX
-Xmx1000m
- $HADOOP_OPTS
-Dcom.sun.management.jmxremote -Dhadoop.log.dir=/usr/local/hadoop/bin/../logs -Dhadoop.log.file=hadoop.log -Dhadoop.home.dir=/usr/local/hadoop/bin/.. -Dhadoop.id.str= -Dhadoop.root.logger=INFO,console -Djava.library.path=/usr/local/hadoop/bin/../lib/native/Linux-amd64-64 -Dhadoop.policy.file=hadoop-policy.xml
- $CLASSPATH:
$HADOOP_HOME/conf
$HADOOP_HOME/hadoop-0.20.2-core.jar
$HADOOP_HOME/lib/*.jar
/usr/java/latest/lib/tools.jar
system env
- $CLASS(根据命令参数,觉得调用哪个Class)
if [ "$COMMAND" = "namenode" ] ; then
CLASS='org.apache.hadoop.hdfs.server.namenode.NameNode'
HADOOP_OPTS="$HADOOP_OPTS $HADOOP_NAMENODE_OPTS"
.......
elif [ "$COMMAND" = "job" ] ; then
CLASS=org.apache.hadoop.mapred.JobClient
elif [ "$COMMAND" = "jar" ] ; then
CLASS=org.apache.hadoop.util.RunJar
else
CLASS=$COMMAND
fi
- $@
命令行输入参数,举例:hadoop jar MyLife.jar -abc -go,则$@值为“MyLife.jar -abc -go”
标签:bin,Dhadoop,jar,hadoop,HADOOP,解析,CLASS From: https://blog.51cto.com/u_16187922/6715124