hadoop_archives.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <meta content="Apache Forrest" name="Generator">
  6. <meta name="Forrest-version" content="0.8">
  7. <meta name="Forrest-skin-name" content="pelt">
  8. <title>Hadoop Archives</title>
  9. <link type="text/css" href="skin/basic.css" rel="stylesheet">
  10. <link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet">
  11. <link media="print" type="text/css" href="skin/print.css" rel="stylesheet">
  12. <link type="text/css" href="skin/profile.css" rel="stylesheet">
  13. <script src="skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="skin/fontsize.js" language="javascript" type="text/javascript"></script>
  14. <link rel="shortcut icon" href="images/favicon.ico">
  15. </head>
  16. <body onload="init()">
  17. <script type="text/javascript">ndeSetTextSize();</script>
  18. <div id="top">
  19. <!--+
  20. |breadtrail
  21. +-->
  22. <div class="breadtrail">
  23. <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://hadoop.apache.org/">Hadoop</a> &gt; <a href="http://hadoop.apache.org/core/">Core</a><script src="skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
  24. </div>
  25. <!--+
  26. |header
  27. +-->
  28. <div class="header">
  29. <!--+
  30. |start group logo
  31. +-->
  32. <div class="grouplogo">
  33. <a href="http://hadoop.apache.org/"><img class="logoImage" alt="Hadoop" src="images/hadoop-logo.jpg" title="Apache Hadoop"></a>
  34. </div>
  35. <!--+
  36. |end group logo
  37. +-->
  38. <!--+
  39. |start Project Logo
  40. +-->
  41. <div class="projectlogo">
  42. <a href="http://hadoop.apache.org/core/"><img class="logoImage" alt="Hadoop" src="images/core-logo.gif" title="Scalable Computing Platform"></a>
  43. </div>
  44. <!--+
  45. |end Project Logo
  46. +-->
  47. <!--+
  48. |start Search
  49. +-->
  50. <div class="searchbox">
  51. <form action="http://www.google.com/search" method="get" class="roundtopsmall">
  52. <input value="hadoop.apache.org" name="sitesearch" type="hidden"><input onFocus="getBlank (this, 'Search the site with google');" size="25" name="q" id="query" type="text" value="Search the site with google">&nbsp;
  53. <input name="Search" value="Search" type="submit">
  54. </form>
  55. </div>
  56. <!--+
  57. |end search
  58. +-->
  59. <!--+
  60. |start Tabs
  61. +-->
  62. <ul id="tabs">
  63. <li>
  64. <a class="unselected" href="http://hadoop.apache.org/core/">Project</a>
  65. </li>
  66. <li>
  67. <a class="unselected" href="http://wiki.apache.org/hadoop">Wiki</a>
  68. </li>
  69. <li class="current">
  70. <a class="selected" href="index.html">Hadoop 0.20 Documentation</a>
  71. </li>
  72. </ul>
  73. <!--+
  74. |end Tabs
  75. +-->
  76. </div>
  77. </div>
  78. <div id="main">
  79. <div id="publishedStrip">
  80. <!--+
  81. |start Subtabs
  82. +-->
  83. <div id="level2tabs"></div>
  84. <!--+
  85. |end Endtabs
  86. +-->
  87. <script type="text/javascript"><!--
  88. document.write("Last Published: " + document.lastModified);
  89. // --></script>
  90. </div>
  91. <!--+
  92. |breadtrail
  93. +-->
  94. <div class="breadtrail">
  95. &nbsp;
  96. </div>
  97. <!--+
  98. |start Menu, mainarea
  99. +-->
  100. <!--+
  101. |start Menu
  102. +-->
  103. <div id="menu">
  104. <div onclick="SwitchMenu('menu_selected_1.1', 'skin/')" id="menu_selected_1.1Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">Documentation</div>
  105. <div id="menu_selected_1.1" class="selectedmenuitemgroup" style="display: block;">
  106. <div class="menuitem">
  107. <a href="index.html">Overview</a>
  108. </div>
  109. <div class="menuitem">
  110. <a href="quickstart.html">Hadoop Quick Start</a>
  111. </div>
  112. <div class="menuitem">
  113. <a href="cluster_setup.html">Hadoop Cluster Setup</a>
  114. </div>
  115. <div class="menuitem">
  116. <a href="mapred_tutorial.html">Hadoop Map/Reduce Tutorial</a>
  117. </div>
  118. <div class="menuitem">
  119. <a href="commands_manual.html">Hadoop Command Guide</a>
  120. </div>
  121. <div class="menuitem">
  122. <a href="hdfs_shell.html">Hadoop FS Shell Guide</a>
  123. </div>
  124. <div class="menuitem">
  125. <a href="distcp.html">Hadoop DistCp Guide</a>
  126. </div>
  127. <div class="menuitem">
  128. <a href="native_libraries.html">Hadoop Native Libraries</a>
  129. </div>
  130. <div class="menuitem">
  131. <a href="streaming.html">Hadoop Streaming</a>
  132. </div>
  133. <div class="menupage">
  134. <div class="menupagetitle">Hadoop Archives</div>
  135. </div>
  136. <div class="menuitem">
  137. <a href="hdfs_user_guide.html">HDFS User Guide</a>
  138. </div>
  139. <div class="menuitem">
  140. <a href="hdfs_design.html">HDFS Architecture</a>
  141. </div>
  142. <div class="menuitem">
  143. <a href="hdfs_permissions_guide.html">HDFS Admin Guide: Permissions</a>
  144. </div>
  145. <div class="menuitem">
  146. <a href="hdfs_quota_admin_guide.html">HDFS Admin Guide: Quotas</a>
  147. </div>
  148. <div class="menuitem">
  149. <a href="SLG_user_guide.html">HDFS Utilities</a>
  150. </div>
  151. <div class="menuitem">
  152. <a href="hod_user_guide.html">HOD User Guide</a>
  153. </div>
  154. <div class="menuitem">
  155. <a href="hod_admin_guide.html">HOD Admin Guide</a>
  156. </div>
  157. <div class="menuitem">
  158. <a href="hod_config_guide.html">HOD Config Guide</a>
  159. </div>
  160. <div class="menuitem">
  161. <a href="capacity_scheduler.html">Capacity Scheduler</a>
  162. </div>
  163. <div class="menuitem">
  164. <a href="api/index.html">API Docs</a>
  165. </div>
  166. <div class="menuitem">
  167. <a href="jdiff/changes.html">API Changes</a>
  168. </div>
  169. <div class="menuitem">
  170. <a href="http://wiki.apache.org/hadoop/">Wiki</a>
  171. </div>
  172. <div class="menuitem">
  173. <a href="http://wiki.apache.org/hadoop/FAQ">FAQ</a>
  174. </div>
  175. <div class="menuitem">
  176. <a href="releasenotes.html">Release Notes</a>
  177. </div>
  178. <div class="menuitem">
  179. <a href="changes.html">Change Log</a>
  180. </div>
  181. </div>
  182. <div id="credit"></div>
  183. <div id="roundbottom">
  184. <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
  185. <!--+
  186. |alternative credits
  187. +-->
  188. <div id="credit2"></div>
  189. </div>
  190. <!--+
  191. |end Menu
  192. +-->
  193. <!--+
  194. |start content
  195. +-->
  196. <div id="content">
  197. <div title="Portable Document Format" class="pdflink">
  198. <a class="dida" href="hadoop_archives.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
  199. PDF</a>
  200. </div>
  201. <h1>Hadoop Archives</h1>
  202. <div id="minitoc-area">
  203. <ul class="minitoc">
  204. <li>
  205. <a href="#What+are+Hadoop+archives%3F"> What are Hadoop archives? </a>
  206. </li>
  207. <li>
  208. <a href="#How+to+create+an+archive%3F"> How to create an archive? </a>
  209. </li>
  210. <li>
  211. <a href="#How+to+look+up+files+in+archives%3F"> How to look up files in archives? </a>
  212. </li>
  213. </ul>
  214. </div>
  215. <a name="N1000D"></a><a name="What+are+Hadoop+archives%3F"></a>
  216. <h2 class="h3"> What are Hadoop archives? </h2>
  217. <div class="section">
  218. <p>
  219. Hadoop archives are special format archives. A Hadoop archive
  220. maps to a file system directory. A Hadoop archive always has a *.har
  221. extension. A Hadoop archive directory contains metadata (in the form
  222. of _index and _masterindex) and data (part-*) files. The _index file contains
  223. the name of the files that are part of the archive and the location
  224. within the part files.
  225. </p>
  226. </div>
  227. <a name="N10017"></a><a name="How+to+create+an+archive%3F"></a>
  228. <h2 class="h3"> How to create an archive? </h2>
  229. <div class="section">
  230. <p>
  231. <span class="codefrag">Usage: hadoop archive -archiveName name &lt;src&gt;* &lt;dest&gt;</span>
  232. </p>
  233. <p>
  234. -archiveName is the name of the archive you would like to create.
  235. An example would be foo.har. The name should have a *.har extension.
  236. The inputs are file system pathnames which work as usual with regular
  237. expressions. The destination directory would contain the archive.
  238. Note that this is a Map/Reduce job that creates the archives. You would
  239. need a map reduce cluster to run this. The following is an example:</p>
  240. <p>
  241. <span class="codefrag">hadoop archive -archiveName foo.har /user/hadoop/dir1 /user/hadoop/dir2 /user/zoo/</span>
  242. </p>
  243. <p>
  244. In the above example /user/hadoop/dir1 and /user/hadoop/dir2 will be
  245. archived in the following file system directory -- /user/zoo/foo.har.
  246. The sources are not changed or removed when an archive is created.
  247. </p>
  248. </div>
  249. <a name="N1002F"></a><a name="How+to+look+up+files+in+archives%3F"></a>
  250. <h2 class="h3"> How to look up files in archives? </h2>
  251. <div class="section">
  252. <p>
  253. The archive exposes itself as a file system layer. So all the fs shell
  254. commands in the archives work but with a different URI. Also, note that
  255. archives are immutable. So, rename's, deletes and creates return
  256. an error. URI for Hadoop Archives is
  257. </p>
  258. <p>
  259. <span class="codefrag">har://scheme-hostname:port/archivepath/fileinarchive</span>
  260. </p>
  261. <p>
  262. If no scheme is provided it assumes the underlying filesystem.
  263. In that case the URI would look like
  264. </p>
  265. <p>
  266. <span class="codefrag">
  267. har:///archivepath/fileinarchive</span>
  268. </p>
  269. <p>
  270. Here is an example of archive. The input to the archives is /dir. The directory dir contains
  271. files filea, fileb. To archive /dir to /user/hadoop/foo.har, the command is
  272. </p>
  273. <p>
  274. <span class="codefrag">hadoop archive -archiveName foo.har /dir /user/hadoop</span>
  275. </p>
  276. <p>
  277. To get file listing for files in the created archive
  278. </p>
  279. <p>
  280. <span class="codefrag">hadoop dfs -lsr har:///user/hadoop/foo.har</span>
  281. </p>
  282. <p>To cat filea in archive -
  283. </p>
  284. <p>
  285. <span class="codefrag">hadoop dfs -cat har:///user/hadoop/foo.har/dir/filea</span>
  286. </p>
  287. </div>
  288. </div>
  289. <!--+
  290. |end content
  291. +-->
  292. <div class="clearboth">&nbsp;</div>
  293. </div>
  294. <div id="footer">
  295. <!--+
  296. |start bottomstrip
  297. +-->
  298. <div class="lastmodified">
  299. <script type="text/javascript"><!--
  300. document.write("Last Published: " + document.lastModified);
  301. // --></script>
  302. </div>
  303. <div class="copyright">
  304. Copyright &copy;
  305. 2008 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
  306. </div>
  307. <!--+
  308. |end bottomstrip
  309. +-->
  310. </div>
  311. </body>
  312. </html>