程式扎記: [ Doc ] Hadoop 2.5.1 - Setting up a Single Node Cluster

標籤

2014年11月17日 星期一

[ Doc ] Hadoop 2.5.1 - Setting up a Single Node Cluster

Source From Here
Purpose
This document describes how to set up and configure a single-node Hadoop installation so that you can quickly perform simple operations using Hadoop MapReduce and the Hadoop Distributed File System (HDFS).

Prerequisites
Supported Platforms
* GNU/Linux is supported as a development and production platform. Hadoop has been demonstrated on GNU/Linux clusters with 2000 nodes.
* Windows is also a supported platform but the followings steps are for Linux only. To set up Hadoop on Windows, see wiki page.

Required Software
Required software for Linux include:
1. Java™ must be installed. Recommended Java versions are described at HadoopJavaVersions.
2. ssh must be installed and sshd must be running to use the Hadoop scripts that manage remote Hadoop daemons.

Installing Software
If your cluster doesn't have the requisite software you will need to install it. For example on Ubuntu Linux:
$ sudo apt-get install ssh
$ sudo apt-get install rsync

Download
To get a Hadoop distribution, download a recent stable release from one of the Apache Download Mirrors.

Prepare to Start the Hadoop Cluster
Unpack the downloaded Hadoop distribution. In the distribution, edit the file etc/hadoop/hadoop-env.sh to define some parameters as follows:
  1. # set to the root of your Java installation if JAVA_HOME not exist  
  2. export JAVA_HOME=/usr/java/latest  
  3.   
  4. # Assuming your installation directory is /home/hduser/hadoop  
  5. export HADOOP_PREFIX=/home/hduser/hadoop  
  6. ...  
Then add the below setting to /etc/profile and enable the setting:
$ sudo vim /etc/profile
  1. ...  
  2. export HADOOP_HOME=/home/usr/hadoop  
  3. export PATH=$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH  
$ . /etc/profile # Enable the settting

Try the following command:
$ hadoop version
Hadoop 2.5.1
Subversion https://git-wip-us.apache.org/repos/asf/hadoop.git -r 2e18d179e4a8065b6a9f29cf2de9451891265cce
...

This will display the usage documentation for the hadoop script. Now you are ready to start your Hadoop cluster in one of the three supported modes:

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.
$ mkdir input
$ cp etc/hadoop/*.xml input
$ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.1.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.

Configuration
Modify the following configuration files:
- etc/hadoop/core-site.xml:
  1.   
  2.       
  3.         fs.defaultFS  
  4.         hdfs://localhost:9000  
  •     
  •   
  •   - etc/hadoop/hdfs-site.xml:
    1.   
    2.       
    3.         dfs.replication  
    4.         1  
  •     
  •   
  •   Setup passphraseless ssh
    Please refer to "SSH 免密碼登入" and make sure the account running hadoop can login localhost. Now check that you can ssh to the localhost without a passphrase:
    $ ssh localhost

    Execution
    The following instructions are to run a MapReduce job locally. If you want to execute a job on YARN, see YARN on Single Node.
    $ hdfs namenode -format # Format the filesystem (Step1)
    14/11/17 17:46:51 INFO util.ExitUtil: Exiting with status 0
    14/11/17 17:46:51 INFO namenode.NameNode: SHUTDOWN_MSG:
    /************************************************************
    SHUTDOWN_MSG: Shutting down NameNode at centosnn/127.0.0.1
    ************************************************************/

    $ start-dfs.sh # Start NameNode daemon and DataNode daemon (Step2)
    # The hadoop daemon log output is written to the $HADOOP_LOG_DIR directory (defaults to $HADOOP_HOME/logs).
    ...
    starting namenode, logging to /home/hduser/hadoop/logs/hadoop-hduser-namenode-centosnn.out
    starting datanode, logging to /home/hduser/hadoop/logs/hadoop-hduser-datanode-centosnn.out
    starting secondarynamenode, logging to /home/hduser/hadoop/logs/hadoop-hduser-secondarynamenode-centosnn.out
    ...

    $ jps # Make sure below processes are up (Step3)
    13593 SecondaryNameNode
    13707 Jps
    13296 NameNode
    13424 DataNode
     

    Browse the web interface for the NameNode; by default it is available at: http://[hadoop_place_ip]:50070/ (Below example: hadoop_place-ip=192.168.192.199)


    Let's make some operations on the built-up single node cluster:
    # Make the HDFS directories required to execute MapReduce jobs (Step4)
    $ hdfs dfs -mkdir /user
    $ hdfs dfs -mkdir /user/hduser
    $ hdfs dfs -ls /user # Or "hadoop fs -ls /user/"
    drwxr-xr-x - hduser supergroup 0 2014-11-17 18:22 /user/hduser

    # Copy the input files into the distributed filesystem:
    $ hdfs dfs -put hadoop/etc/hadoop input # Store folder hadoop/etc/hadoop into HDFS as /user/hduser/input
    $ hdfs dfs -ls /user/hduser
    drwxr-xr-x - hduser supergroup 0 2014-11-17 18:30 /user/hduser/input

    # Run some of the examples provided:
    $ hadoop jar hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.1.jar grep input output 'dfs[a-z.]+'

    # Examine the output files:
    $ hdfs dfs -get output output # Copy folder /user/hduser/output in HDFS back to current real file system path as output folder
    $ cat output/* # View the output files on the distributed filesystem
    6 dfs.audit.logger
    4 dfs.class
    3 dfs.server.namenode.
    2 dfs.period
    ...


    # When you're done, stop the daemons with
    $ stop-dfs.sh

    YARN on Single Node
    You can run a MapReduce job on YARN in a pseudo-distributed mode by setting a few parameters and running ResourceManager daemon and NodeManager daemon in addition. The following instructions assume that 1. ~ 4. steps of the above instructions are already executed.

    Configure parameters as follows:
    - etc/hadoop/mapred-site.xml:
    $ cp hadoop/etc/hadoop/mapred-site.xml.template hadoop/etc/hadoop/mapred-site.xml
    $ vi hadoop/etc/hadoop/mapred-site.xml
    1.   
    2.       
    3.         mapreduce.framework.name  
    4.         yarn  
    5.     
      
  •   - etc/hadoop/yarn-site.xml:
    $ vi hadoop/etc/hadoop/yarn-site.xml
    1.   
    2.       
    3.         yarn.nodemanager.aux-services  
    4.         mapreduce_shuffle  
    5.     
      
  •  
    Start ResourceManager daemon and NodeManager daemon:
    $ start-yarn.sh
    starting yarn daemons
    starting resourcemanager, logging to /home/hduser/hadoop/logs/yarn-hduser-resourcemanager-centosnn.out
    localhost: starting nodemanager, logging to /home/hduser/hadoop/logs/yarn-hduser-nodemanager-centosnn.out

    $ jps
    15708 ResourceManager
    15436 SecondaryNameNode
    15809 NodeManager
    15138 NameNode
    15878 Jps
    15267 DataNode

    Browse the web interface for the ResourceManager; by default it is available at port=8088:


    When you're done, stop the daemons with:
    $ stop-yarn.sh

    Fully-Distributed Operation
    For information on setting up fully-distributed, non-trivial clusters see Cluster Setup.

    Supplement
    Hadoop “Unable to load native-hadoop library for your platform” error on CentOS
    I assume you're running Hadoop on 64bit CentOS. The reason you saw that warning is the native Hadoop library $HADOOP_HOME/lib/native/libhadoop.so.1.0.0 was actually compiled on 32 bit.

    Anyway, it's just a warning, and won't impact Hadoop's functionalities. Here is the way if you do want to eliminate this warning, download the source code of Hadoop and recompile libhadoop.so.1.0.0 on 64bit system, then replace the 32bit one...


    沒有留言:

    張貼留言

    網誌存檔

    關於我自己

    我的相片
    Where there is a will, there is a way!