CommandsManual.apt.vm 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. ~~ Licensed to the Apache Software Foundation (ASF) under one or more
  2. ~~ contributor license agreements. See the NOTICE file distributed with
  3. ~~ this work for additional information regarding copyright ownership.
  4. ~~ The ASF licenses this file to You under the Apache License, Version 2.0
  5. ~~ (the "License"); you may not use this file except in compliance with
  6. ~~ the License. You may obtain a copy of the License at
  7. ~~
  8. ~~ http://www.apache.org/licenses/LICENSE-2.0
  9. ~~
  10. ~~ Unless required by applicable law or agreed to in writing, software
  11. ~~ distributed under the License is distributed on an "AS IS" BASIS,
  12. ~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. ~~ See the License for the specific language governing permissions and
  14. ~~ limitations under the License.
  15. ---
  16. Hadoop Commands Guide
  17. ---
  18. ---
  19. ${maven.build.timestamp}
  20. %{toc}
  21. Overview
  22. All hadoop commands are invoked by the <<<bin/hadoop>>> script. Running the
  23. hadoop script without any arguments prints the description for all
  24. commands.
  25. Usage: <<<hadoop [--config confdir] [COMMAND] [GENERIC_OPTIONS] [COMMAND_OPTIONS]>>>
  26. Hadoop has an option parsing framework that employs parsing generic
  27. options as well as running classes.
  28. *-----------------------+---------------+
  29. || COMMAND_OPTION || Description
  30. *-----------------------+---------------+
  31. | <<<--config confdir>>>| Overwrites the default Configuration directory. Default is <<<${HADOOP_HOME}/conf>>>.
  32. *-----------------------+---------------+
  33. | GENERIC_OPTIONS | The common set of options supported by multiple commands.
  34. | COMMAND_OPTIONS | Various commands with their options are described in the following sections. The commands have been grouped into User Commands and Administration Commands.
  35. *-----------------------+---------------+
  36. Generic Options
  37. The following options are supported by {{dfsadmin}}, {{fs}}, {{fsck}},
  38. {{job}} and {{fetchdt}}. Applications should implement {{{some_useful_url}Tool}} to support
  39. {{{another_useful_url}GenericOptions}}.
  40. *------------------------------------------------+-----------------------------+
  41. || GENERIC_OPTION || Description
  42. *------------------------------------------------+-----------------------------+
  43. |<<<-conf \<configuration file\> >>> | Specify an application
  44. | configuration file.
  45. *------------------------------------------------+-----------------------------+
  46. |<<<-D \<property\>=\<value\> >>> | Use value for given property.
  47. *------------------------------------------------+-----------------------------+
  48. |<<<-jt \<local\> or \<jobtracker:port\> >>> | Specify a job tracker.
  49. | Applies only to job.
  50. *------------------------------------------------+-----------------------------+
  51. |<<<-files \<comma separated list of files\> >>> | Specify comma separated files
  52. | to be copied to the map
  53. | reduce cluster. Applies only
  54. | to job.
  55. *------------------------------------------------+-----------------------------+
  56. |<<<-libjars \<comma seperated list of jars\> >>>| Specify comma separated jar
  57. | files to include in the
  58. | classpath. Applies only to
  59. | job.
  60. *------------------------------------------------+-----------------------------+
  61. |<<<-archives \<comma separated list of archives\> >>> | Specify comma separated
  62. | archives to be unarchived on
  63. | the compute machines. Applies
  64. | only to job.
  65. *------------------------------------------------+-----------------------------+
  66. User Commands
  67. Commands useful for users of a hadoop cluster.
  68. * <<<archive>>>
  69. Creates a hadoop archive. More information can be found at Hadoop
  70. Archives.
  71. Usage: <<<hadoop archive -archiveName NAME <src>* <dest> >>>
  72. *-------------------+-------------------------------------------------------+
  73. ||COMMAND_OPTION || Description
  74. *-------------------+-------------------------------------------------------+
  75. | -archiveName NAME | Name of the archive to be created.
  76. *-------------------+-------------------------------------------------------+
  77. | src | Filesystem pathnames which work as usual with regular
  78. | expressions.
  79. *-------------------+-------------------------------------------------------+
  80. | dest | Destination directory which would contain the archive.
  81. *-------------------+-------------------------------------------------------+
  82. * <<<distcp>>>
  83. Copy file or directories recursively. More information can be found at
  84. Hadoop DistCp Guide.
  85. Usage: <<<hadoop distcp <srcurl> <desturl> >>>
  86. *-------------------+--------------------------------------------+
  87. ||COMMAND_OPTION || Description
  88. *-------------------+--------------------------------------------+
  89. | srcurl | Source Url
  90. *-------------------+--------------------------------------------+
  91. | desturl | Destination Url
  92. *-------------------+--------------------------------------------+
  93. * <<<fs>>>
  94. Usage: <<<hadoop fs [GENERIC_OPTIONS] [COMMAND_OPTIONS]>>>
  95. Deprecated, use <<<hdfs dfs>>> instead.
  96. Runs a generic filesystem user client.
  97. The various COMMAND_OPTIONS can be found at File System Shell Guide.
  98. * <<<fsck>>>
  99. Runs a HDFS filesystem checking utility. See {{Fsck}} for more info.
  100. Usage: <<<hadoop fsck [GENERIC_OPTIONS] <path> [-move | -delete | -openforwrite] [-files [-blocks [-locations | -racks]]]>>>
  101. *------------------+---------------------------------------------+
  102. || COMMAND_OPTION || Description
  103. *------------------+---------------------------------------------+
  104. | <path> | Start checking from this path.
  105. *------------------+---------------------------------------------+
  106. | -move | Move corrupted files to /lost+found
  107. *------------------+---------------------------------------------+
  108. | -delete | Delete corrupted files.
  109. *------------------+---------------------------------------------+
  110. | -openforwrite | Print out files opened for write.
  111. *------------------+---------------------------------------------+
  112. | -files | Print out files being checked.
  113. *------------------+---------------------------------------------+
  114. | -blocks | Print out block report.
  115. *------------------+---------------------------------------------+
  116. | -locations | Print out locations for every block.
  117. *------------------+---------------------------------------------+
  118. | -racks | Print out network topology for data-node locations.
  119. *------------------+---------------------------------------------+
  120. * <<<fetchdt>>>
  121. Gets Delegation Token from a NameNode. See {{fetchdt}} for more info.
  122. Usage: <<<hadoop fetchdt [GENERIC_OPTIONS] [--webservice <namenode_http_addr>] <path> >>>
  123. *------------------------------+---------------------------------------------+
  124. || COMMAND_OPTION || Description
  125. *------------------------------+---------------------------------------------+
  126. | <fileName> | File name to store the token into.
  127. *------------------------------+---------------------------------------------+
  128. | --webservice <https_address> | use http protocol instead of RPC
  129. *------------------------------+---------------------------------------------+
  130. * <<<jar>>>
  131. Runs a jar file. Users can bundle their Map Reduce code in a jar file and
  132. execute it using this command.
  133. Usage: <<<hadoop jar <jar> [mainClass] args...>>>
  134. The streaming jobs are run via this command. Examples can be referred from
  135. Streaming examples
  136. Word count example is also run using jar command. It can be referred from
  137. Wordcount example
  138. * <<<job>>>
  139. Command to interact with Map Reduce Jobs.
  140. Usage: <<<hadoop job [GENERIC_OPTIONS] [-submit <job-file>] | [-status <job-id>] | [-counter <job-id> <group-name> <counter-name>] | [-kill <job-id>] | [-events <job-id> <from-event-#> <#-of-events>] | [-history [all] <jobOutputDir>] | [-list [all]] | [-kill-task <task-id>] | [-fail-task <task-id>] | [-set-priority <job-id> <priority>]>>>
  141. *------------------------------+---------------------------------------------+
  142. || COMMAND_OPTION || Description
  143. *------------------------------+---------------------------------------------+
  144. | -submit <job-file> | Submits the job.
  145. *------------------------------+---------------------------------------------+
  146. | -status <job-id> | Prints the map and reduce completion
  147. | percentage and all job counters.
  148. *------------------------------+---------------------------------------------+
  149. | -counter <job-id> <group-name> <counter-name> | Prints the counter value.
  150. *------------------------------+---------------------------------------------+
  151. | -kill <job-id> | Kills the job.
  152. *------------------------------+---------------------------------------------+
  153. | -events <job-id> <from-event-#> <#-of-events> | Prints the events' details
  154. | received by jobtracker for the given range.
  155. *------------------------------+---------------------------------------------+
  156. | -history [all]<jobOutputDir> | Prints job details, failed and killed tip
  157. | details. More details about the job such as
  158. | successful tasks and task attempts made for
  159. | each task can be viewed by specifying the [all]
  160. | option.
  161. *------------------------------+---------------------------------------------+
  162. | -list [all] | Displays jobs which are yet to complete.
  163. | <<<-list all>>> displays all jobs.
  164. *------------------------------+---------------------------------------------+
  165. | -kill-task <task-id> | Kills the task. Killed tasks are NOT counted
  166. | against failed attempts.
  167. *------------------------------+---------------------------------------------+
  168. | -fail-task <task-id> | Fails the task. Failed tasks are counted
  169. | against failed attempts.
  170. *------------------------------+---------------------------------------------+
  171. | -set-priority <job-id> <priority> | Changes the priority of the job. Allowed
  172. | priority values are VERY_HIGH, HIGH, NORMAL,
  173. | LOW, VERY_LOW
  174. *------------------------------+---------------------------------------------+
  175. * <<<pipes>>>
  176. Runs a pipes job.
  177. Usage: <<<hadoop pipes [-conf <path>] [-jobconf <key=value>, <key=value>,
  178. ...] [-input <path>] [-output <path>] [-jar <jar file>] [-inputformat
  179. <class>] [-map <class>] [-partitioner <class>] [-reduce <class>] [-writer
  180. <class>] [-program <executable>] [-reduces <num>]>>>
  181. *----------------------------------------+------------------------------------+
  182. || COMMAND_OPTION || Description
  183. *----------------------------------------+------------------------------------+
  184. | -conf <path> | Configuration for job
  185. *----------------------------------------+------------------------------------+
  186. | -jobconf <key=value>, <key=value>, ... | Add/override configuration for job
  187. *----------------------------------------+------------------------------------+
  188. | -input <path> | Input directory
  189. *----------------------------------------+------------------------------------+
  190. | -output <path> | Output directory
  191. *----------------------------------------+------------------------------------+
  192. | -jar <jar file> | Jar filename
  193. *----------------------------------------+------------------------------------+
  194. | -inputformat <class> | InputFormat class
  195. *----------------------------------------+------------------------------------+
  196. | -map <class> | Java Map class
  197. *----------------------------------------+------------------------------------+
  198. | -partitioner <class> | Java Partitioner
  199. *----------------------------------------+------------------------------------+
  200. | -reduce <class> | Java Reduce class
  201. *----------------------------------------+------------------------------------+
  202. | -writer <class> | Java RecordWriter
  203. *----------------------------------------+------------------------------------+
  204. | -program <executable> | Executable URI
  205. *----------------------------------------+------------------------------------+
  206. | -reduces <num> | Number of reduces
  207. *----------------------------------------+------------------------------------+
  208. * <<<queue>>>
  209. command to interact and view Job Queue information
  210. Usage: <<<hadoop queue [-list] | [-info <job-queue-name> [-showJobs]] | [-showacls]>>>
  211. *-----------------+-----------------------------------------------------------+
  212. || COMMAND_OPTION || Description
  213. *-----------------+-----------------------------------------------------------+
  214. | -list | Gets list of Job Queues configured in the system.
  215. | Along with scheduling information associated with the job queues.
  216. *-----------------+-----------------------------------------------------------+
  217. | -info <job-queue-name> [-showJobs] | Displays the job queue information and
  218. | associated scheduling information of particular job queue.
  219. | If <<<-showJobs>>> options is present a list of jobs
  220. | submitted to the particular job queue is displayed.
  221. *-----------------+-----------------------------------------------------------+
  222. | -showacls | Displays the queue name and associated queue operations
  223. | allowed for the current user. The list consists of only
  224. | those queues to which the user has access.
  225. *-----------------+-----------------------------------------------------------+
  226. * <<<version>>>
  227. Prints the version.
  228. Usage: <<<hadoop version>>>
  229. * <<<CLASSNAME>>>
  230. hadoop script can be used to invoke any class.
  231. Usage: <<<hadoop CLASSNAME>>>
  232. Runs the class named <<<CLASSNAME>>>.
  233. * <<<classpath>>>
  234. Prints the class path needed to get the Hadoop jar and the required
  235. libraries.
  236. Usage: <<<hadoop classpath>>>
  237. Administration Commands
  238. Commands useful for administrators of a hadoop cluster.
  239. * <<<balancer>>>
  240. Runs a cluster balancing utility. An administrator can simply press Ctrl-C
  241. to stop the rebalancing process. See Rebalancer for more details.
  242. Usage: <<<hadoop balancer [-threshold <threshold>]>>>
  243. *------------------------+-----------------------------------------------------------+
  244. || COMMAND_OPTION | Description
  245. *------------------------+-----------------------------------------------------------+
  246. | -threshold <threshold> | Percentage of disk capacity. This overwrites the
  247. | default threshold.
  248. *------------------------+-----------------------------------------------------------+
  249. * <<<daemonlog>>>
  250. Get/Set the log level for each daemon.
  251. Usage: <<<hadoop daemonlog -getlevel <host:port> <name> >>>
  252. Usage: <<<hadoop daemonlog -setlevel <host:port> <name> <level> >>>
  253. *------------------------------+-----------------------------------------------------------+
  254. || COMMAND_OPTION || Description
  255. *------------------------------+-----------------------------------------------------------+
  256. | -getlevel <host:port> <name> | Prints the log level of the daemon running at
  257. | <host:port>. This command internally connects
  258. | to http://<host:port>/logLevel?log=<name>
  259. *------------------------------+-----------------------------------------------------------+
  260. | -setlevel <host:port> <name> <level> | Sets the log level of the daemon
  261. | running at <host:port>. This command internally
  262. | connects to http://<host:port>/logLevel?log=<name>
  263. *------------------------------+-----------------------------------------------------------+
  264. * <<<datanode>>>
  265. Runs a HDFS datanode.
  266. Usage: <<<hadoop datanode [-rollback]>>>
  267. *-----------------+-----------------------------------------------------------+
  268. || COMMAND_OPTION || Description
  269. *-----------------+-----------------------------------------------------------+
  270. | -rollback | Rollsback the datanode to the previous version. This should
  271. | be used after stopping the datanode and distributing the old
  272. | hadoop version.
  273. *-----------------+-----------------------------------------------------------+
  274. * <<<dfsadmin>>>
  275. Runs a HDFS dfsadmin client.
  276. Usage: <<<hadoop dfsadmin [GENERIC_OPTIONS] [-report] [-safemode enter | leave | get | wait] [-refreshNodes] [-finalizeUpgrade] [-upgradeProgress status | details | force] [-metasave filename] [-setQuota <quota> <dirname>...<dirname>] [-clrQuota <dirname>...<dirname>] [-restoreFailedStorage true|false|check] [-help [cmd]]>>>
  277. *-----------------+-----------------------------------------------------------+
  278. || COMMAND_OPTION || Description
  279. *-----------------+-----------------------------------------------------------+
  280. | -report | Reports basic filesystem information and statistics.
  281. *-----------------+-----------------------------------------------------------+
  282. | -safemode enter / leave / get / wait | Safe mode maintenance command. Safe
  283. | mode is a Namenode state in which it \
  284. | 1. does not accept changes to the name space (read-only) \
  285. | 2. does not replicate or delete blocks. \
  286. | Safe mode is entered automatically at Namenode startup, and
  287. | leaves safe mode automatically when the configured minimum
  288. | percentage of blocks satisfies the minimum replication
  289. | condition. Safe mode can also be entered manually, but then
  290. | it can only be turned off manually as well.
  291. *-----------------+-----------------------------------------------------------+
  292. | -refreshNodes | Re-read the hosts and exclude files to update the set of
  293. | Datanodes that are allowed to connect to the Namenode and
  294. | those that should be decommissioned or recommissioned.
  295. *-----------------+-----------------------------------------------------------+
  296. | -finalizeUpgrade| Finalize upgrade of HDFS. Datanodes delete their previous
  297. | version working directories, followed by Namenode doing the
  298. | same. This completes the upgrade process.
  299. *-----------------+-----------------------------------------------------------+
  300. | -upgradeProgress status / details / force | Request current distributed
  301. | upgrade status, a detailed status or force the upgrade to
  302. | proceed.
  303. *-----------------+-----------------------------------------------------------+
  304. | -metasave filename | Save Namenode's primary data structures to <filename> in
  305. | the directory specified by hadoop.log.dir property.
  306. | <filename> is overwritten if it exists.
  307. | <filename> will contain one line for each of the following\
  308. | 1. Datanodes heart beating with Namenode\
  309. | 2. Blocks waiting to be replicated\
  310. | 3. Blocks currrently being replicated\
  311. | 4. Blocks waiting to be deleted\
  312. *-----------------+-----------------------------------------------------------+
  313. | -setQuota <quota> <dirname>...<dirname> | Set the quota <quota> for each
  314. | directory <dirname>. The directory quota is a long integer
  315. | that puts a hard limit on the number of names in the
  316. | directory tree. Best effort for the directory, with faults
  317. | reported if \
  318. | 1. N is not a positive integer, or \
  319. | 2. user is not an administrator, or \
  320. | 3. the directory does not exist or is a file, or \
  321. | 4. the directory would immediately exceed the new quota. \
  322. *-----------------+-----------------------------------------------------------+
  323. | -clrQuota <dirname>...<dirname> | Clear the quota for each directory
  324. | <dirname>. Best effort for the directory. with fault
  325. | reported if \
  326. | 1. the directory does not exist or is a file, or \
  327. | 2. user is not an administrator. It does not fault if the
  328. | directory has no quota.
  329. *-----------------+-----------------------------------------------------------+
  330. | -restoreFailedStorage true / false / check | This option will turn on/off automatic attempt to restore failed storage replicas.
  331. | If a failed storage becomes available again the system will attempt to restore
  332. | edits and/or fsimage during checkpoint. 'check' option will return current setting.
  333. *-----------------+-----------------------------------------------------------+
  334. | -help [cmd] | Displays help for the given command or all commands if none
  335. | is specified.
  336. *-----------------+-----------------------------------------------------------+
  337. * <<<mradmin>>>
  338. Runs MR admin client
  339. Usage: <<<hadoop mradmin [ GENERIC_OPTIONS ] [-refreshQueueAcls]>>>
  340. *-------------------+-----------------------------------------------------------+
  341. || COMMAND_OPTION || Description
  342. *-------------------+-----------------------------------------------------------+
  343. | -refreshQueueAcls | Refresh the queue acls used by hadoop, to check access
  344. | during submissions and administration of the job by the
  345. | user. The properties present in mapred-queue-acls.xml is
  346. | reloaded by the queue manager.
  347. *-------------------+-----------------------------------------------------------+
  348. * <<<jobtracker>>>
  349. Runs the MapReduce job Tracker node.
  350. Usage: <<<hadoop jobtracker [-dumpConfiguration]>>>
  351. *--------------------+-----------------------------------------------------------+
  352. || COMMAND_OPTION || Description
  353. *--------------------+-----------------------------------------------------------+
  354. | -dumpConfiguration | Dumps the configuration used by the JobTracker alongwith
  355. | queue configuration in JSON format into Standard output
  356. | used by the jobtracker and exits.
  357. *--------------------+-----------------------------------------------------------+
  358. * <<<namenode>>>
  359. Runs the namenode. More info about the upgrade, rollback and finalize is
  360. at Upgrade Rollback
  361. Usage: <<<hadoop namenode [-format] | [-upgrade] | [-rollback] | [-finalize] | [-importCheckpoint]>>>
  362. *--------------------+-----------------------------------------------------------+
  363. || COMMAND_OPTION || Description
  364. *--------------------+-----------------------------------------------------------+
  365. | -format | Formats the namenode. It starts the namenode, formats
  366. | it and then shut it down.
  367. *--------------------+-----------------------------------------------------------+
  368. | -upgrade | Namenode should be started with upgrade option after
  369. | the distribution of new hadoop version.
  370. *--------------------+-----------------------------------------------------------+
  371. | -rollback | Rollsback the namenode to the previous version. This
  372. | should be used after stopping the cluster and
  373. | distributing the old hadoop version.
  374. *--------------------+-----------------------------------------------------------+
  375. | -finalize | Finalize will remove the previous state of the files
  376. | system. Recent upgrade will become permanent. Rollback
  377. | option will not be available anymore. After finalization
  378. | it shuts the namenode down.
  379. *--------------------+-----------------------------------------------------------+
  380. | -importCheckpoint | Loads image from a checkpoint directory and save it
  381. | into the current one. Checkpoint dir is read from
  382. | property fs.checkpoint.dir
  383. *--------------------+-----------------------------------------------------------+
  384. * <<<secondarynamenode>>>
  385. Runs the HDFS secondary namenode. See Secondary Namenode for more
  386. info.
  387. Usage: <<<hadoop secondarynamenode [-checkpoint [force]] | [-geteditsize]>>>
  388. *----------------------+-----------------------------------------------------------+
  389. || COMMAND_OPTION || Description
  390. *----------------------+-----------------------------------------------------------+
  391. | -checkpoint [-force] | Checkpoints the Secondary namenode if EditLog size
  392. | >= fs.checkpoint.size. If <<<-force>>> is used,
  393. | checkpoint irrespective of EditLog size.
  394. *----------------------+-----------------------------------------------------------+
  395. | -geteditsize | Prints the EditLog size.
  396. *----------------------+-----------------------------------------------------------+
  397. * <<<tasktracker>>>
  398. Runs a MapReduce task Tracker node.
  399. Usage: <<<hadoop tasktracker>>>