hdfs.cmd 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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
  17. setlocal enabledelayedexpansion
  18. if not defined HADOOP_BIN_PATH (
  19. set HADOOP_BIN_PATH=%~dp0
  20. )
  21. if "%HADOOP_BIN_PATH:~-1%" == "\" (
  22. set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
  23. )
  24. @rem Determine log file name.
  25. @rem If we're being called by --service we need to use %2.
  26. @rem If we're being called with --config we need to use %3.
  27. @rem Otherwise use %1
  28. if "%1" == "--config" (
  29. set HADOOP_LOGFILE=hadoop-%3-%computername%.log
  30. ) else if "%2" == "" (
  31. set HADOOP_LOGFILE=hadoop-%1-%computername%.log
  32. ) else (
  33. set HADOOP_LOGFILE=hadoop-%2-%computername%.log
  34. )
  35. @rem if running as a service, log to (daily rolling) files instead of console
  36. if "%1" == "--service" (
  37. if not defined HADOOP_ROOT_LOGGER (
  38. set HADOOP_ROOT_LOGGER=INFO,DRFA
  39. )
  40. )
  41. set DEFAULT_LIBEXEC_DIR=%HADOOP_BIN_PATH%\..\libexec
  42. if not defined HADOOP_LIBEXEC_DIR (
  43. set HADOOP_LIBEXEC_DIR=%DEFAULT_LIBEXEC_DIR%
  44. )
  45. call %HADOOP_LIBEXEC_DIR%\hdfs-config.cmd %*
  46. if "%1" == "--config" (
  47. shift
  48. shift
  49. )
  50. if "%1" == "--service" (
  51. set service_entry=true
  52. shift
  53. )
  54. :main
  55. if exist %HADOOP_CONF_DIR%\hadoop-env.cmd (
  56. call %HADOOP_CONF_DIR%\hadoop-env.cmd
  57. )
  58. set hdfs-command=%1
  59. call :make_command_arguments %*
  60. if not defined hdfs-command (
  61. goto print_usage
  62. )
  63. set hdfscommands=dfs namenode secondarynamenode journalnode zkfc datanode dfsadmin haadmin fsck balancer jmxget oiv oev fetchdt getconf groups snapshotDiff lsSnapshottableDir cacheadmin mover storagepolicies
  64. for %%i in ( %hdfscommands% ) do (
  65. if %hdfs-command% == %%i set hdfscommand=true
  66. )
  67. if defined hdfscommand (
  68. call :%hdfs-command%
  69. ) else (
  70. set CLASSPATH=%CLASSPATH%;%CD%
  71. set CLASS=%hdfs-command%
  72. )
  73. set java_arguments=%JAVA_HEAP_MAX% %HADOOP_OPTS% -classpath %CLASSPATH% %CLASS% %hdfs-command-arguments%
  74. if defined service_entry (
  75. call :makeServiceXml %java_arguments%
  76. ) else (
  77. call %JAVA% %java_arguments%
  78. )
  79. goto :eof
  80. :namenode
  81. set CLASS=org.apache.hadoop.hdfs.server.namenode.NameNode
  82. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_NAMENODE_OPTS%
  83. goto :eof
  84. :journalnode
  85. set CLASS=org.apache.hadoop.hdfs.qjournal.server.JournalNode
  86. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_JOURNALNODE_OPTS%
  87. goto :eof
  88. :zkfc
  89. set CLASS=org.apache.hadoop.hdfs.tools.DFSZKFailoverController
  90. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_ZKFC_OPTS%
  91. goto :eof
  92. :secondarynamenode
  93. set CLASS=org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode
  94. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_SECONDARYNAMENODE_OPTS%
  95. goto :eof
  96. :datanode
  97. set CLASS=org.apache.hadoop.hdfs.server.datanode.DataNode
  98. set HADOOP_OPTS=%HADOOP_OPTS% -server %HADOOP_DATANODE_OPTS%
  99. goto :eof
  100. :dfs
  101. set CLASS=org.apache.hadoop.fs.FsShell
  102. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  103. goto :eof
  104. :dfsadmin
  105. set CLASS=org.apache.hadoop.hdfs.tools.DFSAdmin
  106. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  107. goto :eof
  108. :haadmin
  109. set CLASS=org.apache.hadoop.hdfs.tools.DFSHAAdmin
  110. set CLASSPATH=%CLASSPATH%;%TOOL_PATH%
  111. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  112. goto :eof
  113. :fsck
  114. set CLASS=org.apache.hadoop.hdfs.tools.DFSck
  115. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  116. goto :eof
  117. :balancer
  118. set CLASS=org.apache.hadoop.hdfs.server.balancer.Balancer
  119. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_BALANCER_OPTS%
  120. goto :eof
  121. :jmxget
  122. set CLASS=org.apache.hadoop.hdfs.tools.JMXGet
  123. goto :eof
  124. :oiv
  125. set CLASS=org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewerPB
  126. goto :eof
  127. :oev
  128. set CLASS=org.apache.hadoop.hdfs.tools.offlineEditsViewer.OfflineEditsViewer
  129. goto :eof
  130. :fetchdt
  131. set CLASS=org.apache.hadoop.hdfs.tools.DelegationTokenFetcher
  132. goto :eof
  133. :getconf
  134. set CLASS=org.apache.hadoop.hdfs.tools.GetConf
  135. goto :eof
  136. :groups
  137. set CLASS=org.apache.hadoop.hdfs.tools.GetGroups
  138. goto :eof
  139. :snapshotDiff
  140. set CLASS=org.apache.hadoop.hdfs.tools.snapshot.SnapshotDiff
  141. goto :eof
  142. :lsSnapshottableDir
  143. set CLASS=org.apache.hadoop.hdfs.tools.snapshot.LsSnapshottableDir
  144. goto :eof
  145. :cacheadmin
  146. set CLASS=org.apache.hadoop.hdfs.tools.CacheAdmin
  147. goto :eof
  148. :makeServiceXml
  149. set arguments=%*
  150. @echo ^<service^>
  151. @echo ^<id^>%hdfs-command%^</id^>
  152. @echo ^<name^>%hdfs-command%^</name^>
  153. @echo ^<description^>This service runs Hadoop %hdfs-command%^</description^>
  154. @echo ^<executable^>%JAVA%^</executable^>
  155. @echo ^<arguments^>%arguments%^</arguments^>
  156. @echo ^</service^>
  157. :mover
  158. set CLASS=org.apache.hadoop.hdfs.server.mover.Mover
  159. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_MOVER_OPTS%
  160. goto :eof
  161. :storagepolicies
  162. set CLASS=org.apache.hadoop.hdfs.tools.GetStoragePolicies
  163. goto :eof
  164. @rem This changes %1, %2 etc. Hence those cannot be used after calling this.
  165. :make_command_arguments
  166. if [%2] == [] goto :eof
  167. if "%1" == "--config" (
  168. shift
  169. shift
  170. )
  171. if "%1" == "--service" (
  172. shift
  173. )
  174. shift
  175. set _hdfsarguments=
  176. :MakeCmdArgsLoop
  177. if [%1]==[] goto :EndLoop
  178. if not defined _hdfsarguments (
  179. set _hdfsarguments=%1
  180. ) else (
  181. set _hdfsarguments=!_hdfsarguments! %1
  182. )
  183. shift
  184. goto :MakeCmdArgsLoop
  185. :EndLoop
  186. set hdfs-command-arguments=%_hdfsarguments%
  187. goto :eof
  188. :print_usage
  189. @echo Usage: hdfs [--config confdir] COMMAND
  190. @echo where COMMAND is one of:
  191. @echo dfs run a filesystem command on the file systems supported in Hadoop.
  192. @echo namenode -format format the DFS filesystem
  193. @echo secondarynamenode run the DFS secondary namenode
  194. @echo namenode run the DFS namenode
  195. @echo journalnode run the DFS journalnode
  196. @echo zkfc run the ZK Failover Controller daemon
  197. @echo datanode run a DFS datanode
  198. @echo dfsadmin run a DFS admin client
  199. @echo haadmin run a DFS HA admin client
  200. @echo fsck run a DFS filesystem checking utility
  201. @echo balancer run a cluster balancing utility
  202. @echo jmxget get JMX exported values from NameNode or DataNode.
  203. @echo oiv apply the offline fsimage viewer to an fsimage
  204. @echo oev apply the offline edits viewer to an edits file
  205. @echo fetchdt fetch a delegation token from the NameNode
  206. @echo getconf get config values from configuration
  207. @echo groups get the groups which users belong to
  208. @echo snapshotDiff diff two snapshots of a directory or diff the
  209. @echo current directory contents with a snapshot
  210. @echo lsSnapshottableDir list all snapshottable dirs owned by the current user
  211. @echo Use -help to see options
  212. @echo cacheadmin configure the HDFS cache
  213. @echo mover run a utility to move block replicas across storage types
  214. @echo storagepolicies get all the existing block storage policies
  215. @echo.
  216. @echo Most commands print help when invoked w/o parameters.
  217. endlocal