一.hadoop-config.cmd
(1)set HADOOP_HOME=%~dp0
设置HADOOP_HOME=当前目录
(2)set HADOOP_HOME=%HADOOP_HOME:~0,-1%
去掉最后一个’\’符号
(3)set HADOOP_CONF_DIR=%HADOOP_HOME%\etc\hadoop
设置HADOOP_CONF_DIR
(4)set HADOOP_CONF_DIR=%2
–config是第二个参数,把第三个参数指定给HADOOP_CONF_DIR.shift,shift后再计算参数时排除当前这两个
(5)set HADOOP_LOGLEVEL=%2
-loglevel是第二个参数,把第三个参数指定给HADOOP_CONF_DIR
(6)set HADOOP_SLAVES=%HADOOP_CONF_DIR%\%2
–hosts是第二个参数,把第三个参数指定给HADOOP_CONF_DIR
(8)set JAVA=%JAVA_HOME%\bin\java
设置JAVA=java.exe
(9)set JAVA_HEAP_MAX=-Xmx1000m
设置java堆最大为1000M
(10)set JAVA_HEAP_MAX=-Xmx%HADOOP_HEAPSIZE%m
覆盖上面java的堆参数
(11)set CLASSPATH=%HADOOP_CONF_DIR%
设置CLASSPATH
(12)set CLASSPATH=!CLASSPATH!;%HADOOP_COMMON_HOME%\%HADOOP_COMMON_DIR%
附加CLASSPATH
(13)set HADOOP_LOG_DIR=%HADOOP_HOME%\logs
定义日志目录
(14)set HADOOP_LOGFILE=hadoop.log
定义日志文件名
(15)set HADOOP_LOGLEVEL=INFO
定义日志输出级别
(16)set HADOOP_POLICYFILE=hadoop-policy.xml
设置安全权限相关内容
(17)for /f "delims=" %%A in ('%JAVA% -Xmx32m %HADOOP_JAVA_PLATFORM_OPTS% -classpath "%CLASSPATH%" org.apache.hadoop.util.PlatformName') do set JAVA_PLATFORM=%%A
%%A代表in里面的每个字符串(用空格区分)。设置JAVA_PLATFORM执行命令,%JAVA%就是xxx/java.exe,后面跟着java的参数.
(18)set JAVA_LIBRARY_PATH=%HADOOP_COMMON_HOME%\target\bin
设置java类库路径
(19)set TOOL_PATH=%HADOOP_HOME%\share\hadoop\tools\lib\*
设置javatool路径
(20)`
set HADOOP_OPTS=%HADOOP_OPTS% -Dhadoop.log.dir=%HADOOP_LOG_DIR%`
set HADOOP_OPTS=%HADOOP_OPTS% -Dhadoop.log.file=%HADOOP_LOGFILE%
set HADOOP_OPTS=%HADOOP_OPTS% -Dhadoop.home.dir=%HADOOP_HOME%
set HADOOP_OPTS=%HADOOP_OPTS% -Dhadoop.id.str=%HADOOP_IDENT_STRING%
set HADOOP_OPTS=%HADOOP_OPTS% -Dhadoop.root.logger=%HADOOP_ROOT_LOGG
定义hadoop的选项加上日志相关参数
(22)set HADOOP_OPTS=%HADOOP_OPTS% -Dhadoop.policy.file=%HADOOP_POLICYFILE%
定义hadoop的选项加上策略
(23)set CLASSPATH=!CLASSPATH!;%HADOOP_HDFS_HOME%\%HDFS_DIR%
设置CLASSPATH
二.hadoop-env.cmd
(1)set JAVA_HOME=%JAVA_HOME%
设置java_home
(2)set HADOOP_CLASSPATH=%HADOOP_HOME%\contrib\capacity-scheduler\*.jar
设置HADOOP_CLASSPATH
(3)set HADOOP_SECURITY_LOGGER=INFO,RFAS
设置日志环境变量
(4)set HDFS_AUDIT_LOGGER=INFO,NullAppender
设置日志环境变量
(5)set HADOOP_NAMENODE_OPTS=-Dhadoop.security.logger=%HADOOP_SECURITY_LOGGER% -Dhdfs.audit.logger=%HDFS_AUDIT_LOGGER% %HADOOP_NAMENODE_OPTS%
设置名称节点选项
(6)set HADOOP_DATANODE_OPTS=-Dhadoop.security.logger=ERROR,RFAS %HADOOP_DATANODE_OPTS%
设置数据节点选项
(7)set HADOOP_SECONDARYNAMENODE_OPTS=-Dhadoop.security.logger=%HADOOP_SECURITY_LOGGER%
设置备份节点选项
(8)set HADOOP_CLIENT_OPTS=-Xmx512m %HADOOP_CLIENT_OPTS%
设置客户端选项
(9)set HADOOP_SECURE_DN_USER=%HADOOP_SECURE_DN_USER%
设置安全日志
(10)set HADOOP_SECURE_DN_LOG_DIR=%HADOOP_LOG_DIR%\%HADOOP_HDFS_USER%
设置安全日志
(11)set HADOOP_PID_DIR=%HADOOP_PID_DIR%
设置PID文件目录
(12)set HADOOP_SECURE_DN_PID_DIR=%HADOOP_PID_DIR%
设置PID文件存储
(13)set HADOOP_IDENT_STRING=%USERNAME%
设置审计记录
三.start-dfs.cmd
(1)set HADOOP_BIN_PATH=%~dp0
设置HADOOP_HOME=当前目录
(2)set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
去掉最后一个’\’符号
(3)call %HADOOP_LIBEXEC_DIR%\hdfs-config.cmd %*
调用hdfs-config.cmd(此处有后续)
(4)start "Apache Hadoop Distribution" hadoop namenode
启动一个单独的窗口运行一个新程序。 “Apache Hadoop Distribution”窗口的标题。hadoop是一个可执行文件(此处有后续)
(5)start "Apache Hadoop Distribution" hadoop datanode
启动一个单独的窗口运行一个新程序。 “Apache Hadoop Distribution”窗口的标题。hadoop是一个可执行文件(此处有后续)
四.hdfs-config.cmd
(1)set HADOOP_BIN_PATH=%~dp0
(同上)
(2)set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
(同上)
(3)set HADOOP_LIBEXEC_DIR=%DEFAULT_LIBEXEC_DIR%
(同上)
(4) call %HADOOP_LIBEXEC_DIR%\hadoop-config.cmd %*
调用hadoop-config.cmd(此处有后续)
五.hadoop.cmd
(1)set HADOOP_BIN_PATH=%~dp0 (同上)
(2) set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
(同上)
(3)call :updatepath %HADOOP_BIN_PATH%
:updatepath是标签,在本配置文件的下方,先执行此段逻辑。
(4)set HADOOP_LIBEXEC_DIR=%DEFAULT_LIBEXEC_DIR%
(同上)
(5)call %HADOOP_LIBEXEC_DIR%\hadoop-config.cmd %*
调用hadoop-config.cmd
(6)set hadoop-command=%1
提取第一个参数
(7)call :make_command_arguments %*
调用标签make_command_arguments
(8)set hdfscommands=namenode secondarynamenode datanode dfs dfsadmin fsck balancer fetchdt oiv dfsgroups
设置hdfs的hdfscommands命令集合
(9)call %HADOOP_HDFS_HOME%\bin\hdfs.cmd %*
调用hdfs.cmd(此处有后续)
(10)set mapredcommands=pipes job queue mrgroups mradmin jobtracker tasktracker
设置mapred的mapredcommands命令集合
(11)call %HADOOP_MAPRED_HOME%\bin\mapred.cmd %*
调用mapred.cmd(此处有后续)
(12)set corecommands=fs version jar checknative distcp daemonlog archive classpath credential key
设置核心命令集合(fs为文件系统,version为查看版本,jar为运行jar包中的类,checknative为本地类库,distcp为并行拷贝…)
(13)call :%hadoop-command%
调用hadoop-command标签
(14)set CLASS=%hadoop-command%
将命令名称作为class的值
(15)call %JAVA% %JAVA_HEAP_MAX% %HADOOP_OPTS% -classpath %CLASSPATH% %CLASS% %hadoop-command-arguments%
调用java程序(JAVA_HEAP_MAX为java堆的最大值,hadoop-command-arguments为hadoop命令行参数)
六.hdfs.cmd
(1)set HADOOP_BIN_PATH=%~dp0
(同上)
(2)set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
(同上)
(3)set DEFAULT_LIBEXEC_DIR=%HADOOP_BIN_PATH%\..\libexec
(同上)
(4)call %HADOOP_LIBEXEC_DIR%\hdfs-config.cmd %*
调用hdfs-config.cmd
(5)call %HADOOP_CONF_DIR%\hadoop-env.cmd
调用hadoop-env.cmd
(6)set hdfs-command=%1
提取第一个参数
(7)call :make_command_arguments %*
调用命令参数标签
(8)set hdfscommands=dfs namenode secondarynamenode journalnode zkfc datanode dfsadmin haadmin fsck balancer jmxget oiv oev fetchdt getconf groups snapshotDiff lsSnapshottableDir cacheadmin mover storagepolicies classpath crypto
设置hdfscommands命令集合
(9)call :%hdfs-command%
调用hdfs参数命令标签
(10)set java_arguments=%JAVA_HEAP_MAX% %HADOOP_OPTS% -classpath %CLASSPATH% %CLASS% %hdfs-command-arguments%
设置java参数
(11)call %JAVA% %java_arguments%
调用java程序
七.mapred.cmd
(1)set HADOOP_BIN_PATH=%~dp0
(同上)
(2)set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
(同上)
(3)set DEFAULT_LIBEXEC_DIR=%HADOOP_BIN_PATH%\..\libexec
设置本地执行目录文件
(4)call %DEFAULT_LIBEXEC_DIR%\mapred-config.cmd %
* 调用mapred-config.cmd(此处有后续)
(5)call %MAPRED_CONF_DIR%\mapred-env.cmd
调用mapred-env.cmd(此处有后续)
(6)set mapred-command=%1
提取第一个参数
(7)call :make_command_arguments %*
调用命令参数标签
(8)set JAVA_HEAP_SIZE=-Xmx%MAPRED_HEAPSIZE%m
设置java堆大小
(9)set CLASSPATH=%HADOOP_CONF_DIR%;%MAPRED_CONF_DIR%;%CLASSPATH%
设置类路径
(10)call :%mapred-command% %mapred-command-arguments%
调用mapred-command标签,mapred-command-arguments
(11)set java_arguments=%JAVA_HEAP_MAX% %HADOOP_OPTS% -classpath %CLASSPATH% %CLASS% %mapred-command-arguments%
设置java参数
(12)call %JAVA% %java_arguments%
调用java程序
八.mapred-config.cmd
(1)set HADOOP_BIN_PATH=%~dp0 (同上)
(2)set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
(同上)
(3)set DEFAULT_LIBEXEC_DIR=%HADOOP_BIN_PATH%\..\libexec
设置本地执行目录文件
(4)call %HADOOP_LIBEXEC_DIR%\hadoop-config.cmd %*
调用hadoop-config.cmd
九.mapred-env.cmd
(1)set HADOOP_JOB_HISTORYSERVER_HEAPSIZE=1000
设置历史作业堆大小
(2)set HADOOP_MAPRED_ROOT_LOGGER=%HADOOP_LOGLEVEL%,RFA
设置mapred根目录日志