CommandsManual.apt.vm 26 KB

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