hadoop_archives.html 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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.18 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">Quickstart</a>
  111. </div>
  112. <div class="menuitem">
  113. <a href="cluster_setup.html">Cluster Setup</a>
  114. </div>
  115. <div class="menuitem">
  116. <a href="hdfs_design.html">HDFS Architecture</a>
  117. </div>
  118. <div class="menuitem">
  119. <a href="hdfs_user_guide.html">HDFS User Guide</a>
  120. </div>
  121. <div class="menuitem">
  122. <a href="hdfs_permissions_guide.html">HDFS Permissions Guide</a>
  123. </div>
  124. <div class="menuitem">
  125. <a href="hdfs_quota_admin_guide.html">HDFS Quotas Administrator Guide</a>
  126. </div>
  127. <div class="menuitem">
  128. <a href="commands_manual.html">Commands Manual</a>
  129. </div>
  130. <div class="menuitem">
  131. <a href="hdfs_shell.html">FS Shell Guide</a>
  132. </div>
  133. <div class="menuitem">
  134. <a href="distcp.html">DistCp Guide</a>
  135. </div>
  136. <div class="menuitem">
  137. <a href="mapred_tutorial.html">Map-Reduce Tutorial</a>
  138. </div>
  139. <div class="menuitem">
  140. <a href="native_libraries.html">Native Hadoop Libraries</a>
  141. </div>
  142. <div class="menuitem">
  143. <a href="streaming.html">Streaming</a>
  144. </div>
  145. <div class="menupage">
  146. <div class="menupagetitle">Hadoop Archives</div>
  147. </div>
  148. <div class="menuitem">
  149. <a href="hod.html">Hadoop On Demand</a>
  150. </div>
  151. <div class="menuitem">
  152. <a href="api/index.html">API Docs</a>
  153. </div>
  154. <div class="menuitem">
  155. <a href="jdiff/changes.html">API Changes</a>
  156. </div>
  157. <div class="menuitem">
  158. <a href="http://wiki.apache.org/hadoop/">Wiki</a>
  159. </div>
  160. <div class="menuitem">
  161. <a href="http://wiki.apache.org/hadoop/FAQ">FAQ</a>
  162. </div>
  163. <div class="menuitem">
  164. <a href="http://hadoop.apache.org/core/mailing_lists.html">Mailing Lists</a>
  165. </div>
  166. <div class="menuitem">
  167. <a href="releasenotes.html">Release Notes</a>
  168. </div>
  169. <div class="menuitem">
  170. <a href="changes.html">All Changes</a>
  171. </div>
  172. </div>
  173. <div id="credit"></div>
  174. <div id="roundbottom">
  175. <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
  176. <!--+
  177. |alternative credits
  178. +-->
  179. <div id="credit2"></div>
  180. </div>
  181. <!--+
  182. |end Menu
  183. +-->
  184. <!--+
  185. |start content
  186. +-->
  187. <div id="content">
  188. <div title="Portable Document Format" class="pdflink">
  189. <a class="dida" href="hadoop_archives.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
  190. PDF</a>
  191. </div>
  192. <h1>Hadoop Archives</h1>
  193. <div id="minitoc-area">
  194. <ul class="minitoc">
  195. <li>
  196. <a href="#What+are+Hadoop+archives%3F"> What are Hadoop archives? </a>
  197. </li>
  198. <li>
  199. <a href="#How+to+create+an+archive%3F"> How to create an archive? </a>
  200. </li>
  201. <li>
  202. <a href="#How+to+look+up+files+in+archives%3F"> How to look up files in archives? </a>
  203. </li>
  204. </ul>
  205. </div>
  206. <a name="N1000D"></a><a name="What+are+Hadoop+archives%3F"></a>
  207. <h2 class="h3"> What are Hadoop archives? </h2>
  208. <div class="section">
  209. <p>
  210. Hadoop archives are special format archives. A Hadoop archive
  211. maps to a file system directory. A Hadoop archive always has a *.har
  212. extension. A Hadoop archive directory contains metadata (in the form
  213. of _index and _masterindex) and data (part-*) files. The _index file contains
  214. the name of the files that are part of the archive and the location
  215. within the part files.
  216. </p>
  217. </div>
  218. <a name="N10017"></a><a name="How+to+create+an+archive%3F"></a>
  219. <h2 class="h3"> How to create an archive? </h2>
  220. <div class="section">
  221. <p>
  222. <span class="codefrag">Usage: hadoop archive -archiveName name &lt;src&gt;* &lt;dest&gt;</span>
  223. </p>
  224. <p>
  225. -archiveName is the name of the archive you would like to create.
  226. An example would be foo.har. The name should have a *.har extension.
  227. The inputs are file system pathnames which work as usual with regular
  228. expressions. The destination directory would contain the archive.
  229. Note that this is a Map/Reduce job that creates the archives. You would
  230. need a map reduce cluster to run this. The following is an example:</p>
  231. <p>
  232. <span class="codefrag">hadoop archive -archiveName foo.har /user/hadoop/dir1 /user/hadoop/dir2 /user/zoo/</span>
  233. </p>
  234. <p>
  235. In the above example /user/hadoop/dir1 and /user/hadoop/dir2 will be
  236. archived in the following file system directory -- /user/zoo/foo.har.
  237. The sources are not changed or removed when an archive is created.
  238. </p>
  239. </div>
  240. <a name="N1002F"></a><a name="How+to+look+up+files+in+archives%3F"></a>
  241. <h2 class="h3"> How to look up files in archives? </h2>
  242. <div class="section">
  243. <p>
  244. The archive exposes itself as a file system layer. So all the fs shell
  245. commands in the archives work but with a different URI. Also, note that
  246. archives are immutable. So, rename's, deletes and creates return
  247. an error. URI for Hadoop Archives is
  248. </p>
  249. <p>
  250. <span class="codefrag">har://scheme-hostname:port/archivepath/fileinarchive</span>
  251. </p>
  252. <p>
  253. If no scheme is provided it assumes the underlying filesystem.
  254. In that case the URI would look like
  255. </p>
  256. <p>
  257. <span class="codefrag">
  258. har:///archivepath/fileinarchive</span>
  259. </p>
  260. <p>
  261. Here is an example of archive. The input to the archives is /dir. The directory dir contains
  262. files filea, fileb. To archive /dir to /user/hadoop/foo.har, the command is
  263. </p>
  264. <p>
  265. <span class="codefrag">hadoop archive -archiveName foo.har /dir /user/hadoop</span>
  266. </p>
  267. <p>
  268. To get file listing for files in the created archive
  269. </p>
  270. <p>
  271. <span class="codefrag">hadoop dfs -lsr har:///user/hadoop/foo.har</span>
  272. </p>
  273. <p>To cat filea in archive -
  274. </p>
  275. <p>
  276. <span class="codefrag">hadoop dfs -cat har:///user/hadoop/foo.har/dir/filea</span>
  277. </p>
  278. </div>
  279. </div>
  280. <!--+
  281. |end content
  282. +-->
  283. <div class="clearboth">&nbsp;</div>
  284. </div>
  285. <div id="footer">
  286. <!--+
  287. |start bottomstrip
  288. +-->
  289. <div class="lastmodified">
  290. <script type="text/javascript"><!--
  291. document.write("Last Published: " + document.lastModified);
  292. // --></script>
  293. </div>
  294. <div class="copyright">
  295. Copyright &copy;
  296. 2007 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
  297. </div>
  298. <!--+
  299. |end bottomstrip
  300. +-->
  301. </div>
  302. </body>
  303. </html>