hdfs.cmd 6.0 KB

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