hdfs.cmd 6.7 KB

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