native_libraries.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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>Native Hadoop Libraries</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="menupage">
  140. <div class="menupagetitle">Native Hadoop Libraries</div>
  141. </div>
  142. <div class="menuitem">
  143. <a href="streaming.html">Streaming</a>
  144. </div>
  145. <div class="menuitem">
  146. <a href="hadoop_archives.html">Hadoop Archives</a>
  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="native_libraries.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
  190. PDF</a>
  191. </div>
  192. <h1>Native Hadoop Libraries</h1>
  193. <div id="minitoc-area">
  194. <ul class="minitoc">
  195. <li>
  196. <a href="#Purpose">Purpose</a>
  197. </li>
  198. <li>
  199. <a href="#Components">Components</a>
  200. </li>
  201. <li>
  202. <a href="#Usage">Usage</a>
  203. </li>
  204. <li>
  205. <a href="#Supported+Platforms">Supported Platforms</a>
  206. </li>
  207. <li>
  208. <a href="#Building+Native+Hadoop+Libraries">Building Native Hadoop Libraries</a>
  209. <ul class="minitoc">
  210. <li>
  211. <a href="#Notes">Notes</a>
  212. </li>
  213. </ul>
  214. </li>
  215. <li>
  216. <a href="#Loading+native+libraries+through+DistributedCache"> Loading native libraries through DistributedCache </a>
  217. </li>
  218. </ul>
  219. </div>
  220. <a name="N1000D"></a><a name="Purpose"></a>
  221. <h2 class="h3">Purpose</h2>
  222. <div class="section">
  223. <p>Hadoop has native implementations of certain components for reasons of
  224. both performance and non-availability of Java implementations. These
  225. components are available in a single, dynamically-linked, native library.
  226. On the *nix platform it is <em>libhadoop.so</em>. This document describes
  227. the usage and details on how to build the native libraries.</p>
  228. </div>
  229. <a name="N1001A"></a><a name="Components"></a>
  230. <h2 class="h3">Components</h2>
  231. <div class="section">
  232. <p>Hadoop currently has the following
  233. <a href="api/org/apache/hadoop/io/compress/CompressionCodec.html">
  234. compression codecs</a> as the native components:</p>
  235. <ul>
  236. <li>
  237. <a href="http://www.zlib.net/">zlib</a>
  238. </li>
  239. <li>
  240. <a href="http://www.gzip.org/">gzip</a>
  241. </li>
  242. <li>
  243. <a href="http://www.oberhumer.com/opensource/lzo/">lzo</a>
  244. </li>
  245. </ul>
  246. <p>Of the above, the availability of native hadoop libraries is imperative
  247. for the lzo and gzip compression codecs to work.</p>
  248. </div>
  249. <a name="N1003D"></a><a name="Usage"></a>
  250. <h2 class="h3">Usage</h2>
  251. <div class="section">
  252. <p>It is fairly simple to use the native hadoop libraries:</p>
  253. <ul>
  254. <li>
  255. Take a look at the
  256. <a href="#Supported+Platforms">supported platforms</a>.
  257. </li>
  258. <li>
  259. Either <a href="http://hadoop.apache.org/core/releases.html#Download">download</a> the pre-built
  260. 32-bit i386-Linux native hadoop libraries (available as part of hadoop
  261. distribution in <span class="codefrag">lib/native</span> directory) or
  262. <a href="#Building+Native+Hadoop+Libraries">build</a> them yourself.
  263. </li>
  264. <li>
  265. Make sure you have either or both of <strong>&gt;zlib-1.2</strong> and
  266. <strong>&gt;lzo2.0</strong> packages for your platform installed;
  267. depending on your needs.
  268. </li>
  269. </ul>
  270. <p>The <span class="codefrag">bin/hadoop</span> script ensures that the native hadoop
  271. library is on the library path via the system property
  272. <em>-Djava.library.path=&lt;path&gt;</em>.</p>
  273. <p>To check everything went alright check the hadoop log files for:</p>
  274. <p>
  275. <span class="codefrag">
  276. DEBUG util.NativeCodeLoader - Trying to load the custom-built
  277. native-hadoop library...
  278. </span>
  279. <br>
  280. <span class="codefrag">
  281. INFO util.NativeCodeLoader - Loaded the native-hadoop library
  282. </span>
  283. </p>
  284. <p>If something goes wrong, then:</p>
  285. <p>
  286. <span class="codefrag">
  287. INFO util.NativeCodeLoader - Unable to load native-hadoop library for
  288. your platform... using builtin-java classes where applicable
  289. </span>
  290. </p>
  291. </div>
  292. <a name="N10087"></a><a name="Supported+Platforms"></a>
  293. <h2 class="h3">Supported Platforms</h2>
  294. <div class="section">
  295. <p>Hadoop native library is supported only on *nix platforms only.
  296. Unfortunately it is known not to work on <a href="http://www.cygwin.com/">Cygwin</a>
  297. and <a href="http://www.apple.com/macosx">Mac OS X</a> and has mainly been used on the
  298. GNU/Linux platform.</p>
  299. <p>It has been tested on the following GNU/Linux distributions:</p>
  300. <ul>
  301. <li>
  302. <a href="http://www.redhat.com/rhel/">RHEL4</a>/<a href="http://fedora.redhat.com/">Fedora</a>
  303. </li>
  304. <li>
  305. <a href="http://www.ubuntu.com/">Ubuntu</a>
  306. </li>
  307. <li>
  308. <a href="http://www.gentoo.org/">Gentoo</a>
  309. </li>
  310. </ul>
  311. <p>On all the above platforms a 32/64 bit Hadoop native library will work
  312. with a respective 32/64 bit jvm.</p>
  313. </div>
  314. <a name="N100B7"></a><a name="Building+Native+Hadoop+Libraries"></a>
  315. <h2 class="h3">Building Native Hadoop Libraries</h2>
  316. <div class="section">
  317. <p>Hadoop native library is written in
  318. <a href="http://en.wikipedia.org/wiki/ANSI_C">ANSI C</a> and built using
  319. the GNU autotools-chain (autoconf, autoheader, automake, autoscan, libtool).
  320. This means it should be straight-forward to build them on any platform with
  321. a standards compliant C compiler and the GNU autotools-chain.
  322. See <a href="#Supported+Platforms">supported platforms</a>.</p>
  323. <p>In particular the various packages you would need on the target
  324. platform are:</p>
  325. <ul>
  326. <li>
  327. C compiler (e.g. <a href="http://gcc.gnu.org/">GNU C Compiler</a>)
  328. </li>
  329. <li>
  330. GNU Autools Chain:
  331. <a href="http://www.gnu.org/software/autoconf/">autoconf</a>,
  332. <a href="http://www.gnu.org/software/automake/">automake</a>,
  333. <a href="http://www.gnu.org/software/libtool/">libtool</a>
  334. </li>
  335. <li>
  336. zlib-development package (stable version &gt;= 1.2.0)
  337. </li>
  338. <li>
  339. lzo-development package (stable version &gt;= 2.0)
  340. </li>
  341. </ul>
  342. <p>Once you have the pre-requisites use the standard <span class="codefrag">build.xml</span>
  343. and pass along the <span class="codefrag">compile.native</span> flag (set to
  344. <span class="codefrag">true</span>) to build the native hadoop library:</p>
  345. <p>
  346. <span class="codefrag">$ ant -Dcompile.native=true &lt;target&gt;</span>
  347. </p>
  348. <p>The native hadoop library is not built by default since not everyone is
  349. interested in building them.</p>
  350. <p>You should see the newly-built native hadoop library in:</p>
  351. <p>
  352. <span class="codefrag">$ build/native/&lt;platform&gt;/lib</span>
  353. </p>
  354. <p>where &lt;platform&gt; is combination of the system-properties:
  355. <span class="codefrag">${os.name}-${os.arch}-${sun.arch.data.model}</span>; for e.g.
  356. Linux-i386-32.</p>
  357. <a name="N1010A"></a><a name="Notes"></a>
  358. <h3 class="h4">Notes</h3>
  359. <ul>
  360. <li>
  361. It is <strong>mandatory</strong> to have both the zlib and lzo
  362. development packages on the target platform for building the
  363. native hadoop library; however for deployment it is sufficient to
  364. install zlib or lzo if you wish to use only one of them.
  365. </li>
  366. <li>
  367. It is necessary to have the correct 32/64 libraries of both zlib/lzo
  368. depending on the 32/64 bit jvm for the target platform for
  369. building/deployment of the native hadoop library.
  370. </li>
  371. </ul>
  372. </div>
  373. <a name="N1011E"></a><a name="Loading+native+libraries+through+DistributedCache"></a>
  374. <h2 class="h3"> Loading native libraries through DistributedCache </h2>
  375. <div class="section">
  376. <p>User can load native shared libraries through
  377. <a href="mapred_tutorial.html#DistributedCache">DistributedCache</a>
  378. for <em>distributing</em> and <em>symlinking</em> the library files</p>
  379. <p>Here is an example, describing how to distribute the library and
  380. load it from map/reduce task. </p>
  381. <ol>
  382. <li> First copy the library to the HDFS. <br>
  383. <span class="codefrag">bin/hadoop fs -copyFromLocal mylib.so.1 /libraries/mylib.so.1</span>
  384. </li>
  385. <li> The job launching program should contain the following: <br>
  386. <span class="codefrag"> DistributedCache.createSymlink(conf); </span>
  387. <br>
  388. <span class="codefrag"> DistributedCache.addCacheFile("hdfs://host:port/libraries/mylib.so.1#mylib.so", conf);
  389. </span>
  390. </li>
  391. <li> The map/reduce task can contain: <br>
  392. <span class="codefrag"> System.loadLibrary("mylib.so"); </span>
  393. </li>
  394. </ol>
  395. </div>
  396. </div>
  397. <!--+
  398. |end content
  399. +-->
  400. <div class="clearboth">&nbsp;</div>
  401. </div>
  402. <div id="footer">
  403. <!--+
  404. |start bottomstrip
  405. +-->
  406. <div class="lastmodified">
  407. <script type="text/javascript"><!--
  408. document.write("Last Published: " + document.lastModified);
  409. // --></script>
  410. </div>
  411. <div class="copyright">
  412. Copyright &copy;
  413. 2007 <a href="http://www.apache.org/licenses/">The Apache Software Foundation.</a>
  414. </div>
  415. <!--+
  416. |end bottomstrip
  417. +-->
  418. </div>
  419. </body>
  420. </html>