CommandsManual.apt.vm 26 KB

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