hadoop.cmd 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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_HEAPSIZE The maximum amount of heap to use, in MB.
  30. @rem Default is 1000.
  31. @rem
  32. @rem HADOOP_OPTS Extra Java runtime options.
  33. @rem
  34. @rem HADOOP_CLIENT_OPTS when the respective command is run.
  35. @rem HADOOP_{COMMAND}_OPTS etc HADOOP_JT_OPTS applies to JobTracker
  36. @rem for e.g. HADOOP_CLIENT_OPTS applies to
  37. @rem more than one command (fs, dfs, fsck,
  38. @rem dfsadmin etc)
  39. @rem
  40. @rem HADOOP_CONF_DIR Alternate conf dir. Default is ${HADOOP_HOME}/conf.
  41. @rem
  42. @rem HADOOP_ROOT_LOGGER The root appender. Default is INFO,console
  43. @rem
  44. if not defined HADOOP_BIN_PATH (
  45. set HADOOP_BIN_PATH=%~dp0
  46. )
  47. if "%HADOOP_BIN_PATH:~-1%" == "\" (
  48. set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
  49. )
  50. call :updatepath %HADOOP_BIN_PATH%
  51. :main
  52. setlocal enabledelayedexpansion
  53. set DEFAULT_LIBEXEC_DIR=%HADOOP_BIN_PATH%\..\libexec
  54. if not defined HADOOP_LIBEXEC_DIR (
  55. set HADOOP_LIBEXEC_DIR=%DEFAULT_LIBEXEC_DIR%
  56. )
  57. call %HADOOP_LIBEXEC_DIR%\hadoop-config.cmd %*
  58. if "%1" == "--config" (
  59. shift
  60. shift
  61. )
  62. if "%1" == "--loglevel" (
  63. shift
  64. shift
  65. )
  66. set hadoop-command=%1
  67. if not defined hadoop-command (
  68. goto print_usage
  69. )
  70. call :make_command_arguments %*
  71. set hdfscommands=namenode secondarynamenode datanode dfs dfsadmin fsck balancer fetchdt oiv dfsgroups
  72. for %%i in ( %hdfscommands% ) do (
  73. if %hadoop-command% == %%i set hdfscommand=true
  74. )
  75. if defined hdfscommand (
  76. @echo DEPRECATED: Use of this script to execute hdfs command is deprecated. 1>&2
  77. @echo Instead use the hdfs command for it. 1>&2
  78. if exist %HADOOP_HDFS_HOME%\bin\hdfs.cmd (
  79. call %HADOOP_HDFS_HOME%\bin\hdfs.cmd %*
  80. goto :eof
  81. ) else if exist %HADOOP_HOME%\bin\hdfs.cmd (
  82. call %HADOOP_HOME%\bin\hdfs.cmd %*
  83. goto :eof
  84. ) else (
  85. echo HADOOP_HDFS_HOME not found!
  86. goto :eof
  87. )
  88. )
  89. set mapredcommands=pipes job queue mrgroups mradmin jobtracker tasktracker
  90. for %%i in ( %mapredcommands% ) do (
  91. if %hadoop-command% == %%i set mapredcommand=true
  92. )
  93. if defined mapredcommand (
  94. @echo DEPRECATED: Use of this script to execute mapred command is deprecated. 1>&2
  95. @echo Instead use the mapred command for it. 1>&2
  96. if exist %HADOOP_MAPRED_HOME%\bin\mapred.cmd (
  97. call %HADOOP_MAPRED_HOME%\bin\mapred.cmd %*
  98. goto :eof
  99. ) else if exist %HADOOP_HOME%\bin\mapred.cmd (
  100. call %HADOOP_HOME%\bin\mapred.cmd %*
  101. goto :eof
  102. ) else (
  103. echo HADOOP_MAPRED_HOME not found!
  104. goto :eof
  105. )
  106. )
  107. if %hadoop-command% == classpath (
  108. if not defined hadoop-command-arguments (
  109. @rem No need to bother starting up a JVM for this simple case.
  110. @echo %CLASSPATH%
  111. exit /b
  112. )
  113. )
  114. set corecommands=fs version jar checknative distcp daemonlog archive classpath credential key
  115. for %%i in ( %corecommands% ) do (
  116. if %hadoop-command% == %%i set corecommand=true
  117. )
  118. if defined corecommand (
  119. call :%hadoop-command%
  120. ) else (
  121. set CLASSPATH=%CLASSPATH%;%CD%
  122. set CLASS=%hadoop-command%
  123. )
  124. set path=%PATH%;%HADOOP_BIN_PATH%
  125. @rem Always respect HADOOP_OPTS and HADOOP_CLIENT_OPTS
  126. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  127. @rem make sure security appender is turned off
  128. if not defined HADOOP_SECURITY_LOGGER (
  129. set HADOOP_SECURITY_LOGGER=INFO,NullAppender
  130. )
  131. set HADOOP_OPTS=%HADOOP_OPTS% -Dhadoop.security.logger=%HADOOP_SECURITY_LOGGER%
  132. call %JAVA% %JAVA_HEAP_MAX% %HADOOP_OPTS% -classpath %CLASSPATH% %CLASS% %hadoop-command-arguments%
  133. exit /b %ERRORLEVEL%
  134. :fs
  135. set CLASS=org.apache.hadoop.fs.FsShell
  136. goto :eof
  137. :version
  138. set CLASS=org.apache.hadoop.util.VersionInfo
  139. goto :eof
  140. :jar
  141. if defined YARN_OPTS (
  142. @echo WARNING: Use "yarn jar" to launch YARN applications. 1>&2
  143. ) else if defined YARN_CLIENT_OPTS (
  144. @echo WARNING: Use "yarn jar" to launch YARN applications. 1>&2
  145. )
  146. set CLASS=org.apache.hadoop.util.RunJar
  147. goto :eof
  148. :checknative
  149. set CLASS=org.apache.hadoop.util.NativeLibraryChecker
  150. goto :eof
  151. :distcp
  152. set CLASS=org.apache.hadoop.tools.DistCp
  153. set CLASSPATH=%CLASSPATH%;%TOOL_PATH%
  154. goto :eof
  155. :daemonlog
  156. set CLASS=org.apache.hadoop.log.LogLevel
  157. goto :eof
  158. :archive
  159. set CLASS=org.apache.hadoop.tools.HadoopArchives
  160. set CLASSPATH=%CLASSPATH%;%TOOL_PATH%
  161. goto :eof
  162. :classpath
  163. set CLASS=org.apache.hadoop.util.Classpath
  164. goto :eof
  165. :credential
  166. set CLASS=org.apache.hadoop.security.alias.CredentialShell
  167. goto :eof
  168. :key
  169. set CLASS=org.apache.hadoop.crypto.key.KeyShell
  170. goto :eof
  171. :updatepath
  172. set path_to_add=%*
  173. set current_path_comparable=%path%
  174. set current_path_comparable=%current_path_comparable: =_%
  175. set current_path_comparable=%current_path_comparable:(=_%
  176. set current_path_comparable=%current_path_comparable:)=_%
  177. set path_to_add_comparable=%path_to_add%
  178. set path_to_add_comparable=%path_to_add_comparable: =_%
  179. set path_to_add_comparable=%path_to_add_comparable:(=_%
  180. set path_to_add_comparable=%path_to_add_comparable:)=_%
  181. for %%i in ( %current_path_comparable% ) do (
  182. if /i "%%i" == "%path_to_add_comparable%" (
  183. set path_to_add_exist=true
  184. )
  185. )
  186. set system_path_comparable=
  187. set path_to_add_comparable=
  188. if not defined path_to_add_exist path=%path_to_add%;%path%
  189. set path_to_add=
  190. goto :eof
  191. @rem This changes %1, %2 etc. Hence those cannot be used after calling this.
  192. :make_command_arguments
  193. if "%1" == "--config" (
  194. shift
  195. shift
  196. )
  197. if "%1" == "--loglevel" (
  198. shift
  199. shift
  200. )
  201. if [%2] == [] goto :eof
  202. shift
  203. set _arguments=
  204. :MakeCmdArgsLoop
  205. if [%1]==[] goto :EndLoop
  206. if not defined _arguments (
  207. set _arguments=%1
  208. ) else (
  209. set _arguments=!_arguments! %1
  210. )
  211. shift
  212. goto :MakeCmdArgsLoop
  213. :EndLoop
  214. set hadoop-command-arguments=%_arguments%
  215. goto :eof
  216. :print_usage
  217. @echo Usage: hadoop [--config confdir] [--loglevel loglevel] COMMAND
  218. @echo where COMMAND is one of:
  219. @echo fs run a generic filesystem user client
  220. @echo version print the version
  221. @echo jar ^<jar^> run a jar file
  222. @echo note: please use "yarn jar" to launch
  223. @echo YARN applications, not this command.
  224. @echo checknative [-a^|-h] check native hadoop and compression libraries availability
  225. @echo distcp ^<srcurl^> ^<desturl^> copy file or directories recursively
  226. @echo archive -archiveName NAME -p ^<parent path^> ^<src^>* ^<dest^> create a hadoop archive
  227. @echo classpath prints the class path needed to get the
  228. @echo Hadoop jar and the required libraries
  229. @echo credential interact with credential providers
  230. @echo key manage keys via the KeyProvider
  231. @echo daemonlog get/set the log level for each daemon
  232. @echo or
  233. @echo CLASSNAME run the class named CLASSNAME
  234. @echo.
  235. @echo Most commands print help when invoked w/o parameters.
  236. endlocal