From ArchWiki
Revision as of 07:38, 25 February 2013 by Yintianjiao (talk | contribs) (fix the link for Hadoop Official Documentation)
Jump to navigation Jump to search

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: Sysvinit is deprecated. We use systemd now. (Discuss in Talk:Hadoop#)

Apache Hadoop is a framework for running applications on large cluster built of commodity hardware. The Hadoop framework transparently provides applications both reliability and data motion. Hadoop implements a computational paradigm named Map/Reduce, where the application is divided into many small fragments of work, each of which may be executed or re-executed on any node in the cluster. In addition, it provides a distributed file system (HDFS) that stores data on the compute nodes, providing very high aggregate bandwidth across the cluster. Both MapReduce and the Hadoop Distributed File System are designed so that node failures are automatically handled by the framework.


Install the hadoopAUR package which is available in the Arch User Repository.


By default, hadoop is already configured for pseudo-distributed operation. Some environment variables are set in /etc/profile.d/hadoop.sh with different value than traditional hadoop.

ENV Value Description Permission
HADOOP_CONF_DIR /etc/hadoop Where configuration files are stored. Read
HADOOP_LOG_DIR /tmp/hadoop/log Where log files are stored. Read and Write
HADOOP_SLAVES /etc/hadoop/slaves File naming remote slave hosts. Read
HADOOP_PID_DIR /tmp/hadoop/run Where pid files are stored. Read and Write

You also should set up follow files correctly.


JAVA_HOME should be set automatically by [jdk7-openjdk] /etc/profile.d/jre.sh or [openjdk6] /etc/profile.d/openjdk6.sh. You could check JAVA_HOME:

$ echo $JAVA_HOME

If it does not print anything, maybe you should logout and login to make it right.

Single Node Setup

Note: This part is base on the Hadoop Official Documentation

Standalone Operation

By default, Hadoop is configured to run in a non-distributed mode, as a single Java process. This is useful for debugging.

The following example copies the unpacked conf directory to use as input and then finds and displays every match of the given regular expression. Output is written to the given output directory.

$ export HADOOP_CONF_DIR=/usr/lib/hadoop/orig_conf
$ mkdir input
$ cp /etc/hadoop/*.xml input
$ hadoop jar /usr/lib/hadoop/hadoop-examples-*.jar grep input output 'dfs[a-z.]+'
$ cat output/*

Pseudo-Distributed Operation

Hadoop can also be run on a single-node in a pseudo-distributed mode where each Hadoop daemon runs in a separate Java process.

By default, Hadoop will run as the user root. If you use initscripts, you can change the user in /etc/conf.d/hadoop-all:

HADOOP_USERNAME="<your user name>"

Setup passphraseless ssh

Now check that you can ssh to the localhost without a passphrase:

$ ssh localhost

If you cannot ssh to localhost without a passphrase, execute the following commands:

$ ssh-keygen -t dsa -P "" -f ~/.ssh/id_dsa
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys 


Format a new distributed-filesystem:

$ hadoop namenode -format

Start the hadoop daemons:

$ sudo systemctl start hadoop-datanode
$ sudo systemctl start hadoop-jobtracker
$ sudo systemctl start hadoop-namenode
$ sudo systemctl start hadoop-secondarynamenode
$ sudo systemctl start hadoop-tasktracker

The hadoop daemon log output is written to the ${HADOOP_LOG_DIR} directory (defaults to /var/log/hadoop).

Browse the web interface for the NameNode and the JobTracker; by default they are available at:

Copy the input files into the distributed filesystem:

$ hadoop fs -put /etc/hadoop input

Run some of the examples provided:

$ hadoop jar /usr/lib/hadoop/hadoop-examples-*.jar grep input output 'dfs[a-z.]+'

Examine the output files:

Copy the output files from the distributed filesystem to the local filesytem and examine them:

$ hadoop fs -get output output
$ cat output/*


View the output files on the distributed filesystem:

$ hadoop fs -cat output/*

When you're done, stop the daemons with:

$ sudo systemctl stop hadoop-datanode
$ sudo systemctl stop hadoop-jobtracker
$ sudo systemctl stop hadoop-namenode
$ sudo systemctl stop hadoop-secondarynamenode
$ sudo systemctl stop hadoop-tasktracker