<p>This document describes how to install and configure Hadoop clusters ranging from a few nodes to extremely large clusters with thousands of nodes. To play with Hadoop, you may first want to install it on a single machine (see <ahref="./SingleCluster.html">Single Node Setup</a>).</p>
<p>This document does not cover advanced topics such as High Availability.</p>
<p><i>Important</i>: all production Hadoop clusters use Kerberos to authenticate callers and secure access to HDFS data as well as restriction access to computation services (YARN etc.).</p>
<p>These instructions do not cover integration with any Kerberos services, -everyone bringing up a production cluster should include connecting to their organisation’s Kerberos infrastructure as a key part of the deployment.</p>
<p>See <ahref="./SecureMode.html">Security</a> for details on how to secure a cluster.</p></section><section>
<h2><aname="Prerequisites"></a>Prerequisites</h2>
<ul>
<li>Install Java. See the <aclass="externalLink"href="https://cwiki.apache.org/confluence/display/HADOOP/Hadoop+Java+Versions">Hadoop Wiki</a> for known good versions.</li>
<li>Download a stable version of Hadoop from Apache mirrors.</li>
</ul></section><section>
<h2><aname="Installation"></a>Installation</h2>
<p>Installing a Hadoop cluster typically involves unpacking the software on all the machines in the cluster or installing it via a packaging system as appropriate for your operating system. It is important to divide up the hardware into functions.</p>
<p>Typically one machine in the cluster is designated as the NameNode and another machine as the ResourceManager, exclusively. These are the masters. Other services (such as Web App Proxy Server and MapReduce Job History server) are usually run either on dedicated hardware or on shared infrastructure, depending upon the load.</p>
<p>The rest of the machines in the cluster act as both DataNode and NodeManager. These are the workers.</p></section><section>
<h2><aname="Configuring_Hadoop_in_Non-Secure_Mode"></a>Configuring Hadoop in Non-Secure Mode</h2>
<p>Hadoop’s Java configuration is driven by two types of important configuration files:</p>
<ul>
<li>
<p>Read-only default configuration - <code>core-default.xml</code>, <code>hdfs-default.xml</code>, <code>yarn-default.xml</code> and <code>mapred-default.xml</code>.</p>
</li>
<li>
<p>Site-specific configuration - <code>etc/hadoop/core-site.xml</code>, <code>etc/hadoop/hdfs-site.xml</code>, <code>etc/hadoop/yarn-site.xml</code> and <code>etc/hadoop/mapred-site.xml</code>.</p>
</li>
</ul>
<p>Additionally, you can control the Hadoop scripts found in the bin/ directory of the distribution, by setting site-specific values via the <code>etc/hadoop/hadoop-env.sh</code> and <code>etc/hadoop/yarn-env.sh</code>.</p>
<p>To configure the Hadoop cluster you will need to configure the <code>environment</code> in which the Hadoop daemons execute as well as the <code>configuration parameters</code> for the Hadoop daemons.</p>
<p>HDFS daemons are NameNode, SecondaryNameNode, and DataNode. YARN daemons are ResourceManager, NodeManager, and WebAppProxy. If MapReduce is to be used, then the MapReduce Job History Server will also be running. For large installations, these are generally running on separate hosts.</p><section>
<h3><aname="Configuring_Environment_of_Hadoop_Daemons"></a>Configuring Environment of Hadoop Daemons</h3>
<p>Administrators should use the <code>etc/hadoop/hadoop-env.sh</code> and optionally the <code>etc/hadoop/mapred-env.sh</code> and <code>etc/hadoop/yarn-env.sh</code> scripts to do site-specific customization of the Hadoop daemons’ process environment.</p>
<p>At the very least, you must specify the <code>JAVA_HOME</code> so that it is correctly defined on each remote node.</p>
<p>Administrators can configure individual daemons using the configuration options shown below in the table:</p>
<p>See <code>etc/hadoop/hadoop-env.sh</code> for other examples.</p>
<p>Other useful configuration parameters that you can customize include:</p>
<ul>
<li><code>HADOOP_PID_DIR</code> - The directory where the daemons’ process id files are stored.</li>
<li><code>HADOOP_LOG_DIR</code> - The directory where the daemons’ log files are stored. Log files are automatically created if they don’t exist.</li>
<li><code>HADOOP_HEAPSIZE_MAX</code> - The maximum amount of memory to use for the Java heapsize. Units supported by the JVM are also supported here. If no unit is present, it will be assumed the number is in megabytes. By default, Hadoop will let the JVM determine how much to use. This value can be overriden on a per-daemon basis using the appropriate <code>_OPTS</code> variable listed above. For example, setting <code>HADOOP_HEAPSIZE_MAX=1g</code> and <code>HADOOP_NAMENODE_OPTS="-Xmx5g"</code> will configure the NameNode with 5GB heap.</li>
</ul>
<p>In most cases, you should specify the <code>HADOOP_PID_DIR</code> and <code>HADOOP_LOG_DIR</code> directories such that they can only be written to by the users that are going to run the hadoop daemons. Otherwise there is the potential for a symlink attack.</p>
<p>It is also traditional to configure <code>HADOOP_HOME</code> in the system-wide shell environment configuration. For example, a simple script inside <code>/etc/profile.d</code>:</p>
<divclass="source">
<divclass="source">
<pre> HADOOP_HOME=/path/to/hadoop
export HADOOP_HOME
</pre></div></div>
</section><section>
<h3><aname="Configuring_the_Hadoop_Daemons"></a>Configuring the Hadoop Daemons</h3>
<p>This section deals with important parameters to be specified in the given configuration files:</p>
<tdalign="left"> Path on the local filesystem where the NameNode stores the namespace and transactions logs persistently. </td>
<tdalign="left"> If this is a comma-delimited list of directories then the name table is replicated in all of the directories, for redundancy. </td></tr>
<tdalign="left"> Comma separated list of paths on the local filesystem of a <code>DataNode</code> where it should store its blocks. </td>
<tdalign="left"> If this is a comma-delimited list of directories, then data will be stored in all named directories, typically on different devices. </td></tr>
</tbody>
</table>
<ul>
<li>
<p><code>etc/hadoop/yarn-site.xml</code></p>
</li>
<li>
<p>Configurations for ResourceManager and NodeManager:</p>
<tdalign="left"> Enable ACLs? Defaults to <i>false</i>. </td></tr>
<trclass="a">
<tdalign="left"><code>yarn.admin.acl</code></td>
<tdalign="left"> Admin ACL </td>
<tdalign="left"> ACL to set admins on the cluster. ACLs are of for <i>comma-separated-usersspacecomma-separated-groups</i>. Defaults to special value of <b>*</b> which means <i>anyone</i>. Special value of just <i>space</i> means no one has access. </td></tr>
<tdalign="left"><i>host</i> Single hostname that can be set in place of setting all <code>yarn.resourcemanager*address</code> resources. Results in default ports for ResourceManager components. </td></tr>
<tdalign="left"><code>CapacityScheduler</code> (recommended), <code>FairScheduler</code> (also recommended), or <code>FifoScheduler</code>. Use a fully qualified class name, e.g., <code>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</code>. </td></tr>
<tdalign="left"> Maximum ratio by which virtual memory usage of tasks may exceed physical memory </td>
<tdalign="left"> The virtual memory usage of each task may exceed its physical memory limit by this ratio. The total amount of virtual memory used by tasks on the NodeManager may exceed its physical memory usage by this ratio. </td></tr>
<tdalign="left"> HDFS directory where the application logs are moved on application completion. Need to set appropriate permissions. Only applicable if log-aggregation is enabled. </td></tr>
<tdalign="left"> Suffix appended to the remote log dir. Logs will be aggregated to ${yarn.nodemanager.remote-app-log-dir}/${user}/${thisParam} Only applicable if log-aggregation is enabled. </td></tr>
<tdalign="left"> Environment properties to be inherited by containers from NodeManagers </td>
<tdalign="left"> For mapreduce application in addition to the default values HADOOP_MAPRED_HOME should to be added. Property value should JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_HOME,PATH,LANG,TZ,HADOOP_MAPRED_HOME </td></tr>
</tbody>
</table>
<ul>
<li>Configurations for History Server (Needs to be moved elsewhere):</li>
<tdalign="left"> How long to keep aggregation logs before deleting them. -1 disables. Be careful, set this too small and you will spam the name node. </td></tr>
<tdalign="left"> Time between checks for aggregated log retention. If set to 0 or a negative value then the value is computed as one-tenth of the aggregated log retention time. Be careful, set this too small and you will spam the name node. </td></tr>
<tdalign="left"> Directory where history files are managed by the MR JobHistory Server. </td></tr>
</tbody>
</table></section></section><section>
<h2><aname="Monitoring_Health_of_NodeManagers"></a>Monitoring Health of NodeManagers</h2>
<p>Hadoop provides a mechanism by which administrators can configure the NodeManager to run an administrator supplied script periodically to determine if a node is healthy or not.</p>
<p>Administrators can determine if the node is in a healthy state by performing any checks of their choice in the script. If the script detects the node to be in an unhealthy state, it must print a line to standard output beginning with the string ERROR. The NodeManager spawns the script periodically and checks its output. If the script’s output contains the string ERROR, as described above, the node’s status is reported as <code>unhealthy</code> and the node is black-listed by the ResourceManager. No further tasks will be assigned to this node. However, the NodeManager continues to run the script, so that if the node becomes healthy again, it will be removed from the blacklisted nodes on the ResourceManager automatically. The node’s health along with the output of the script, if it is unhealthy, is available to the administrator in the ResourceManager web interface. The time since the node was healthy is also displayed on the web interface.</p>
<p>The following parameters can be used to control the node health monitoring script in <code>etc/hadoop/yarn-site.xml</code>.</p>
<tdalign="left"> Node health script timeout interval </td>
<tdalign="left"> Timeout for health script execution. </td></tr>
</tbody>
</table>
<p>The health checker script is not supposed to give ERROR if only some of the local disks become bad. NodeManager has the ability to periodically check the health of the local disks (specifically checks nodemanager-local-dirs and nodemanager-log-dirs) and after reaching the threshold of number of bad directories based on the value set for the config property yarn.nodemanager.disk-health-checker.min-healthy-disks, the whole node is marked unhealthy and this info is sent to resource manager also. The boot disk is either raided or a failure in the boot disk is identified by the health checker script.</p></section><section>
<h2><aname="Slaves_File"></a>Slaves File</h2>
<p>List all worker hostnames or IP addresses in your <code>etc/hadoop/workers</code> file, one per line. Helper scripts (described below) will use the <code>etc/hadoop/workers</code> file to run commands on many hosts at once. It is not used for any of the Java-based Hadoop configuration. In order to use this functionality, ssh trusts (via either passphraseless ssh or some other means, such as Kerberos) must be established for the accounts used to run Hadoop.</p></section><section>
<p>Many Hadoop components are rack-aware and take advantage of the network topology for performance and safety. Hadoop daemons obtain the rack information of the workers in the cluster by invoking an administrator configured module. See the <ahref="./RackAwareness.html">Rack Awareness</a> documentation for more specific information.</p>
<p>It is highly recommended configuring rack awareness prior to starting HDFS.</p></section><section>
<h2><aname="Logging"></a>Logging</h2>
<p>Hadoop uses the <aclass="externalLink"href="http://logging.apache.org/log4j/2.x/">Apache log4j</a> via the Apache Commons Logging framework for logging. Edit the <code>etc/hadoop/log4j.properties</code> file to customize the Hadoop daemons’ logging configuration (log-formats and so on).</p></section><section>
<h2><aname="Operating_the_Hadoop_Cluster"></a>Operating the Hadoop Cluster</h2>
<p>Once all the necessary configuration is complete, distribute the files to the <code>HADOOP_CONF_DIR</code> directory on all the machines. This should be the same directory on all machines.</p>
<p>In general, it is recommended that HDFS and YARN run as separate users. In the majority of installations, HDFS processes execute as ‘hdfs’. YARN is typically using the ‘yarn’ account.</p><section>
<p>If <code>etc/hadoop/workers</code> and ssh trusted access is configured (see <ahref="./SingleCluster.html">Single Node Setup</a>), all of the HDFS processes can be started with a utility script. As <i>hdfs</i>:</p>
<divclass="source">
<divclass="source">
<pre>[hdfs]$ $HADOOP_HOME/sbin/start-dfs.sh
</pre></div></div>
<p>Start the YARN with the following command, run on the designated ResourceManager as <i>yarn</i>:</p>
<p>Start a standalone WebAppProxy server. Run on the WebAppProxy server as <i>yarn</i>. If multiple servers are used with load balancing it should be run on each of them:</p>
<p>If <code>etc/hadoop/workers</code> and ssh trusted access is configured (see <ahref="./SingleCluster.html">Single Node Setup</a>), all of the YARN processes can be started with a utility script. As <i>yarn</i>:</p>
<divclass="source">
<divclass="source">
<pre>[yarn]$ $HADOOP_HOME/sbin/start-yarn.sh
</pre></div></div>
<p>Start the MapReduce JobHistory Server with the following command, run on the designated server as <i>mapred</i>:</p>
<p>If <code>etc/hadoop/workers</code> and ssh trusted access is configured (see <ahref="./SingleCluster.html">Single Node Setup</a>), all of the HDFS processes may be stopped with a utility script. As <i>hdfs</i>:</p>
<divclass="source">
<divclass="source">
<pre>[hdfs]$ $HADOOP_HOME/sbin/stop-dfs.sh
</pre></div></div>
<p>Stop the ResourceManager with the following command, run on the designated ResourceManager as <i>yarn</i>:</p>
<p>If <code>etc/hadoop/workers</code> and ssh trusted access is configured (see <ahref="./SingleCluster.html">Single Node Setup</a>), all of the YARN processes can be stopped with a utility script. As <i>yarn</i>:</p>
<divclass="source">
<divclass="source">
<pre>[yarn]$ $HADOOP_HOME/sbin/stop-yarn.sh
</pre></div></div>
<p>Stop the WebAppProxy server. Run on the WebAppProxy server as <i>yarn</i>. If multiple servers are used with load balancing it should be run on each of them:</p>