overview.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <html>
  2. <head>
  3. <title>Hadoop</title>
  4. </head>
  5. <body>
  6. Hadoop is a distributed computing platform.
  7. <p>Hadoop primarily consists of a distributed filesystem (DFS, in <a
  8. href="org/apache/hadoop/dfs/package-summary.html">org.apache.hadoop.dfs</a>)
  9. and an implementation of a MapReduce distributed data processor (in <a
  10. href="org/apache/hadoop/mapred/package-summary.html">org.apache.hadoop.mapred
  11. </a>).</p>
  12. <h2>Requirements</h2>
  13. <ol>
  14. <li>Java 1.5.x, preferably from <a
  15. href="http://java.sun.com/j2se/downloads.html">Sun</a> Set
  16. <tt>JAVA_HOME</tt> to the root of your Java installation.</li>
  17. <li>ssh must be installed and sshd must be running to use Hadoop's
  18. scripts to manage remote Hadoop daemons. On Ubuntu, this may done
  19. with <br><tt>sudo apt-get install ssh</tt></li>
  20. <li>rsync must be installed to use Hadoop's scripts to manage remote
  21. Hadoop installations. On Ubuntu, this may done with <br><tt>sudo
  22. apt-get install rsync</tt>.</li>
  23. <li>On Win32, <a href="http://www.cygwin.com/">cygwin</a>, for shell
  24. support. To use Subversion on Win32, select the subversion package
  25. when you install, in the "Devel" category. Distributed operation has
  26. not been well tested on Win32, so this should primarily be considered
  27. a development platform at this point, not a production platform.</li>
  28. </ol>
  29. <h2>Getting Started</h2>
  30. <p>First, you need to get a copy of the Hadoop code.</p>
  31. <p>You can download a nightly build from <a
  32. href="http://cvs.apache.org/dist/lucene/hadoop/nightly/">http://cvs.apache.org/dist/lucene/hadoop/nightly/</a>.
  33. Unpack the release and connect to its top-level directory.</p>
  34. <p>Or, check out the code from <a
  35. href="http://lucene.apache.org/hadoop/version_control.html">subversion</a>
  36. and build it with <a href="http://ant.apache.org/">Ant</a>.</p>
  37. <p>Edit the file <tt>conf/hadoop-env.sh</tt> to define at least
  38. <tt>JAVA_HOME</tt>.</p>
  39. <p>Try the following command:</p>
  40. <tt>bin/hadoop</tt>
  41. <p>This will display the documentation for the Hadoop command script.</p>
  42. <h2>Standalone operation</h2>
  43. <p>By default, Hadoop is configured to run things in a non-distributed
  44. mode, as a single Java process. This is useful for debugging, and can
  45. be demonstrated as follows:</p>
  46. <tt>
  47. mkdir input<br>
  48. cp conf/*.xml input<br>
  49. bin/hadoop jar hadoop-*-examples.jar grep input output 'dfs[a-z.]+'<br>
  50. cat output/*
  51. </tt>
  52. <p>This will display counts for each match of the <a
  53. href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html">
  54. regular expression.</a></p>
  55. <p>Note that input is specified as a <em>directory</em> containing input
  56. files and that output is also specified as a directory where parts are
  57. written.</p>
  58. <h2>Distributed operation</h2>
  59. To configure Hadoop for distributed operation you must specify the
  60. following:
  61. <ol>
  62. <li>The {@link org.apache.hadoop.dfs.NameNode} (Distributed Filesystem
  63. master) host and port. This is specified with the configuration
  64. property <tt><a
  65. href="../hadoop-default.html#fs.default.name">fs.default.name</a></tt>.
  66. </li>
  67. <li>The {@link org.apache.hadoop.mapred.JobTracker} (MapReduce master)
  68. host and port. This is specified with the configuration property
  69. <tt><a
  70. href="../hadoop-default.html#mapred.job.tracker">mapred.job.tracker</a></tt>.
  71. </li>
  72. <li>A <em>slaves</em> file that lists the names of all the hosts in
  73. the cluster. The default slaves file is <tt>conf/slaves</tt>.
  74. </ol>
  75. <h3>Pseudo-distributed configuration</h3>
  76. You can in fact run everything on a single host. To run things this
  77. way, put the following in conf/hadoop-site.xml:
  78. <xmp><configuration>
  79. <property>
  80. <name>fs.default.name</name>
  81. <value>localhost:9000</value>
  82. </property>
  83. <property>
  84. <name>mapred.job.tracker</name>
  85. <value>localhost:9001</value>
  86. </property>
  87. <property>
  88. <name>dfs.replication</name>
  89. <value>1</value>
  90. </property>
  91. </configuration></xmp>
  92. <p>(We also set the DFS replication level to 1 in order to
  93. reduce warnings when running on a single node.)</p>
  94. <p>Now check that the command <br><tt>ssh localhost</tt><br> does not
  95. require a password. If it does, execute the following commands:</p>
  96. <p><tt>ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa<br>
  97. cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
  98. </tt></p>
  99. <h3>Bootstrapping</h3>
  100. <p>A new distributed filesystem must be formatted with the following
  101. command, run on the master node:</p>
  102. <p><tt>bin/hadoop namenode -format</tt></p>
  103. <p>The Hadoop daemons are started with the following command:</p>
  104. <p><tt>bin/start-all.sh</tt></p>
  105. <p>Daemon log output is written to the <tt>logs/</tt> directory.</p>
  106. <p>Input files are copied into the distributed filesystem as follows:</p>
  107. <p><tt>bin/hadoop dfs -put input input</tt></p>
  108. <h3>Distributed execution</h3>
  109. <p>Things are run as before, but output must be copied locally to
  110. examine it:</p>
  111. <tt>
  112. bin/hadoop jar hadoop-*-examples.jar grep input output 'dfs[a-z.]+'<br>
  113. bin/hadoop dfs -get output output
  114. cat output/*
  115. </tt>
  116. <p>When you're done, stop the daemons with:</p>
  117. <p><tt>bin/stop-all.sh</tt></p>
  118. <h2>Fully-distributed operation</h2>
  119. <p>Distributed operation is just like the pseudo-distributed operation
  120. described above, except:</p>
  121. <ol>
  122. <li>Specify hostname or IP address of the master server in the values
  123. for <tt><a
  124. href="../hadoop-default.html#fs.default.name">fs.default.name</a></tt>
  125. and <tt><a
  126. href="../hadoop-default.html#mapred.job.tracker">mapred.job.tracker</a></tt>
  127. in <tt>conf/hadoop-site.xml</tt>. These are specified as
  128. <tt><em>host</em>:<em>port</em></tt> pairs.</li>
  129. <li>Specify directories for <tt><a
  130. href="../hadoop-default.html#dfs.name.dir">dfs.name.dir</a></tt> and
  131. <tt><a
  132. href="../hadoop-default.html#dfs.data.dir">dfs.data.dir</a></tt> in
  133. <tt>conf/hadoop-site.xml</tt>. These are used to hold distributed
  134. filesystem data on the master node and slave nodes respectively. Note
  135. that <tt>dfs.data.dir</tt> may contain a space- or comma-separated
  136. list of directory names, so that data may be stored on multiple
  137. devices.</li>
  138. <li>Specify <tt><a
  139. href="../hadoop-default.html#mapred.local.dir">mapred.local.dir</a></tt>
  140. in <tt>conf/hadoop-site.xml</tt>. This determines where temporary
  141. MapReduce data is written. It also may be a list of directories.</li>
  142. <li>Specify <tt><a
  143. href="../hadoop-default.html#mapred.map.tasks">mapred.map.tasks</a></tt>
  144. and <tt><a
  145. href="../hadoop-default.html#mapred.reduce.tasks">mapred.reduce.tasks</a></tt>
  146. in <tt>conf/hadoop-site.xml</tt>. As a rule of thumb, use 10x the
  147. number of slave processors for <tt>mapred.map.tasks</tt>, and 2x the
  148. number of slave processors for <tt>mapred.reduce.tasks</tt>.</li>
  149. <li>List all slave hostnames or IP addresses in your
  150. <tt>conf/slaves</tt> file, one per line.</li>
  151. </ol>
  152. </body>
  153. </html>