hadoop.cmd 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. @echo off
  2. @rem Licensed to the Apache Software Foundation (ASF) under one or more
  3. @rem contributor license agreements. See the NOTICE file distributed with
  4. @rem this work for additional information regarding copyright ownership.
  5. @rem The ASF licenses this file to You under the Apache License, Version 2.0
  6. @rem (the "License"); you may not use this file except in compliance with
  7. @rem the License. You may obtain a copy of the License at
  8. @rem
  9. @rem http://www.apache.org/licenses/LICENSE-2.0
  10. @rem
  11. @rem Unless required by applicable law or agreed to in writing, software
  12. @rem distributed under the License is distributed on an "AS IS" BASIS,
  13. @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. @rem See the License for the specific language governing permissions and
  15. @rem limitations under the License.
  16. @rem This script runs the hadoop core commands.
  17. @rem Environment Variables
  18. @rem
  19. @rem JAVA_HOME The java implementation to use. Overrides JAVA_HOME.
  20. @rem
  21. @rem HADOOP_CLASSPATH Extra Java CLASSPATH entries.
  22. @rem
  23. @rem HADOOP_USER_CLASSPATH_FIRST When defined, the HADOOP_CLASSPATH is
  24. @rem added in the beginning of the global
  25. @rem classpath. Can be defined, for example,
  26. @rem by doing
  27. @rem export HADOOP_USER_CLASSPATH_FIRST=true
  28. @rem
  29. @rem HADOOP_USE_CLIENT_CLASSLOADER When defined, HADOOP_CLASSPATH and the
  30. @rem jar as the hadoop jar argument are
  31. @rem handled by a separate isolated client
  32. @rem classloader. If it is set,
  33. @rem HADOOP_USER_CLASSPATH_FIRST is
  34. @rem ignored. Can be defined by doing
  35. @rem export HADOOP_USE_CLIENT_CLASSLOADER=true
  36. @rem
  37. @rem HADOOP_CLIENT_CLASSLOADER_SYSTEM_CLASSES
  38. @rem When defined, it overrides the default
  39. @rem definition of system classes for the
  40. @rem client classloader when
  41. @rem HADOOP_USE_CLIENT_CLASSLOADER is
  42. @rem enabled. Names ending in '.' (period)
  43. @rem are treated as package names, and names
  44. @rem starting with a '-' are treated as
  45. @rem negative matches. For example,
  46. @rem export HADOOP_CLIENT_CLASSLOADER_SYSTEM_CLASSES="-org.apache.hadoop.UserClass,java.,javax.,org.apache.hadoop."
  47. @rem
  48. @rem HADOOP_HEAPSIZE The maximum amount of heap to use, in MB.
  49. @rem Default is 1000.
  50. @rem
  51. @rem HADOOP_OPTS Extra Java runtime options.
  52. @rem
  53. @rem HADOOP_CLIENT_OPTS when the respective command is run.
  54. @rem HADOOP_{COMMAND}_OPTS etc HADOOP_JT_OPTS applies to JobTracker
  55. @rem for e.g. HADOOP_CLIENT_OPTS applies to
  56. @rem more than one command (fs, dfs, fsck,
  57. @rem dfsadmin etc)
  58. @rem
  59. @rem HADOOP_CONF_DIR Alternate conf dir. Default is ${HADOOP_HOME}/conf.
  60. @rem
  61. @rem HADOOP_ROOT_LOGGER The root appender. Default is INFO,console
  62. @rem
  63. if not defined HADOOP_BIN_PATH (
  64. set HADOOP_BIN_PATH=%~dp0
  65. )
  66. if "%HADOOP_BIN_PATH:~-1%" == "\" (
  67. set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
  68. )
  69. call :updatepath %HADOOP_BIN_PATH%
  70. :main
  71. setlocal enabledelayedexpansion
  72. set DEFAULT_LIBEXEC_DIR=%HADOOP_BIN_PATH%\..\libexec
  73. if not defined HADOOP_LIBEXEC_DIR (
  74. set HADOOP_LIBEXEC_DIR=%DEFAULT_LIBEXEC_DIR%
  75. )
  76. call %HADOOP_LIBEXEC_DIR%\hadoop-config.cmd %*
  77. if "%1" == "--config" (
  78. shift
  79. shift
  80. )
  81. if "%1" == "--loglevel" (
  82. shift
  83. shift
  84. )
  85. set hadoop-command=%1
  86. if not defined hadoop-command (
  87. goto print_usage
  88. )
  89. call :make_command_arguments %*
  90. set hdfscommands=namenode secondarynamenode datanode dfs dfsadmin fsck balancer fetchdt oiv dfsgroups
  91. for %%i in ( %hdfscommands% ) do (
  92. if %hadoop-command% == %%i set hdfscommand=true
  93. )
  94. if defined hdfscommand (
  95. @echo DEPRECATED: Use of this script to execute hdfs command is deprecated. 1>&2
  96. @echo Instead use the hdfs command for it. 1>&2
  97. if exist %HADOOP_HDFS_HOME%\bin\hdfs.cmd (
  98. call %HADOOP_HDFS_HOME%\bin\hdfs.cmd %*
  99. goto :eof
  100. ) else if exist %HADOOP_HOME%\bin\hdfs.cmd (
  101. call %HADOOP_HOME%\bin\hdfs.cmd %*
  102. goto :eof
  103. ) else (
  104. echo HADOOP_HDFS_HOME not found!
  105. goto :eof
  106. )
  107. )
  108. set mapredcommands=pipes job queue mrgroups mradmin jobtracker tasktracker
  109. for %%i in ( %mapredcommands% ) do (
  110. if %hadoop-command% == %%i set mapredcommand=true
  111. )
  112. if defined mapredcommand (
  113. @echo DEPRECATED: Use of this script to execute mapred command is deprecated. 1>&2
  114. @echo Instead use the mapred command for it. 1>&2
  115. if exist %HADOOP_MAPRED_HOME%\bin\mapred.cmd (
  116. call %HADOOP_MAPRED_HOME%\bin\mapred.cmd %*
  117. goto :eof
  118. ) else if exist %HADOOP_HOME%\bin\mapred.cmd (
  119. call %HADOOP_HOME%\bin\mapred.cmd %*
  120. goto :eof
  121. ) else (
  122. echo HADOOP_MAPRED_HOME not found!
  123. goto :eof
  124. )
  125. )
  126. if %hadoop-command% == classpath (
  127. if not defined hadoop-command-arguments (
  128. @rem No need to bother starting up a JVM for this simple case.
  129. @echo %CLASSPATH%
  130. exit /b
  131. )
  132. )
  133. set corecommands=fs version jar checknative distcp daemonlog archive classpath credential key
  134. for %%i in ( %corecommands% ) do (
  135. if %hadoop-command% == %%i set corecommand=true
  136. )
  137. if defined corecommand (
  138. call :%hadoop-command%
  139. ) else (
  140. set CLASSPATH=%CLASSPATH%;%CD%
  141. set CLASS=%hadoop-command%
  142. )
  143. set path=%PATH%;%HADOOP_BIN_PATH%
  144. @rem Always respect HADOOP_OPTS and HADOOP_CLIENT_OPTS
  145. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  146. @rem make sure security appender is turned off
  147. if not defined HADOOP_SECURITY_LOGGER (
  148. set HADOOP_SECURITY_LOGGER=INFO,NullAppender
  149. )
  150. set HADOOP_OPTS=%HADOOP_OPTS% -Dhadoop.security.logger=%HADOOP_SECURITY_LOGGER%
  151. call %JAVA% %JAVA_HEAP_MAX% %HADOOP_OPTS% -classpath %CLASSPATH% %CLASS% %hadoop-command-arguments%
  152. exit /b %ERRORLEVEL%
  153. :fs
  154. set CLASS=org.apache.hadoop.fs.FsShell
  155. goto :eof
  156. :version
  157. if defined YARN_OPTS (
  158. @echo WARNING: Use "yarn jar" to launch YARN applications.
  159. ) else if defined YARN_CLIENT_OPTS (
  160. @echo WARNING: Use "yarn jar" to launch YARN applications.
  161. )
  162. set CLASS=org.apache.hadoop.util.VersionInfo
  163. goto :eof
  164. :jar
  165. set CLASS=org.apache.hadoop.util.RunJar
  166. goto :eof
  167. :checknative
  168. set CLASS=org.apache.hadoop.util.NativeLibraryChecker
  169. goto :eof
  170. :distcp
  171. set CLASS=org.apache.hadoop.tools.DistCp
  172. set CLASSPATH=%CLASSPATH%;%TOOL_PATH%
  173. goto :eof
  174. :daemonlog
  175. set CLASS=org.apache.hadoop.log.LogLevel
  176. goto :eof
  177. :archive
  178. set CLASS=org.apache.hadoop.tools.HadoopArchives
  179. set CLASSPATH=%CLASSPATH%;%TOOL_PATH%
  180. goto :eof
  181. :classpath
  182. set CLASS=org.apache.hadoop.util.Classpath
  183. goto :eof
  184. :credential
  185. set CLASS=org.apache.hadoop.security.alias.CredentialShell
  186. goto :eof
  187. :key
  188. set CLASS=org.apache.hadoop.crypto.key.KeyShell
  189. goto :eof
  190. :updatepath
  191. set path_to_add=%*
  192. set current_path_comparable=%path%
  193. set current_path_comparable=%current_path_comparable: =_%
  194. set current_path_comparable=%current_path_comparable:(=_%
  195. set current_path_comparable=%current_path_comparable:)=_%
  196. set path_to_add_comparable=%path_to_add%
  197. set path_to_add_comparable=%path_to_add_comparable: =_%
  198. set path_to_add_comparable=%path_to_add_comparable:(=_%
  199. set path_to_add_comparable=%path_to_add_comparable:)=_%
  200. for %%i in ( %current_path_comparable% ) do (
  201. if /i "%%i" == "%path_to_add_comparable%" (
  202. set path_to_add_exist=true
  203. )
  204. )
  205. set system_path_comparable=
  206. set path_to_add_comparable=
  207. if not defined path_to_add_exist path=%path_to_add%;%path%
  208. set path_to_add=
  209. goto :eof
  210. @rem This changes %1, %2 etc. Hence those cannot be used after calling this.
  211. :make_command_arguments
  212. if "%1" == "--config" (
  213. shift
  214. shift
  215. )
  216. if "%1" == "--loglevel" (
  217. shift
  218. shift
  219. )
  220. if [%2] == [] goto :eof
  221. shift
  222. set _arguments=
  223. :MakeCmdArgsLoop
  224. if [%1]==[] goto :EndLoop
  225. if not defined _arguments (
  226. set _arguments=%1
  227. ) else (
  228. set _arguments=!_arguments! %1
  229. )
  230. shift
  231. goto :MakeCmdArgsLoop
  232. :EndLoop
  233. set hadoop-command-arguments=%_arguments%
  234. @echo note: please use "yarn jar" to launch
  235. @echo YARN applications, not this command.
  236. goto :eof
  237. :print_usage
  238. @echo Usage: hadoop [--config confdir] [--loglevel loglevel] COMMAND
  239. @echo where COMMAND is one of:
  240. @echo fs run a generic filesystem user client
  241. @echo version print the version
  242. @echo jar ^<jar^> run a jar file
  243. @echo checknative [-a^|-h] check native hadoop and compression libraries availability
  244. @echo distcp ^<srcurl^> ^<desturl^> copy file or directories recursively
  245. @echo archive -archiveName NAME -p ^<parent path^> ^<src^>* ^<dest^> create a hadoop archive
  246. @echo classpath prints the class path needed to get the
  247. @echo Hadoop jar and the required libraries
  248. @echo credential interact with credential providers
  249. @echo key manage keys via the KeyProvider
  250. @echo daemonlog get/set the log level for each daemon
  251. @echo or
  252. @echo CLASSNAME run the class named CLASSNAME
  253. @echo.
  254. @echo Most commands print help when invoked w/o parameters.
  255. endlocal