Hadoop mapreduce next generation-setting up a single node cluster

Source: Internet
Author: User
Tags apache download hdfs dfs hadoop mapreduce
Hadoop mapreduce next generation-setting up a single node cluster.

 

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 ).

Prerequisitessupported platforms
  • GNU/Linux is supported as a development and production platform. hadoop has been demonstrated on GNU/Linux Clusters with 2000 nodes.
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 fileETC/hadoop/hadoop-env.shTo define some parameters as follows:

  # set to the root of your Java installation  export JAVA_HOME=/usr/java/latest  # Assuming your installation directory is /usr/local/hadoop  export HADOOP_PREFIX=/usr/local/hadoop

Try the following command:

  $ bin/hadoop

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:

  • Local (standalone) Mode
  • Pseudo-distributed mode
  • Fully-distributed mode
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.4.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

Use the following:

# etc/hadoop/core-site.xml:<configuration>    <property>        <name>fs.defaultFS</name>        <value>hdfs://localhost:9000</value>    </property></configuration># etc/hadoop/hdfs-site.xml:<configuration>    <property>        <name>dfs.replication</name>        <value>1</value>    </property></configuration>

 

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

 

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.

  1. Format the filesystem:
      $ bin/hdfs namenode -format
  2. Start namenode daemon and datanode daemon:
      $ sbin/start-dfs.sh

    The hadoop daemon log output is written to$ Hadoop_log_dirDirectory (defaults$ Hadoop_home/logs).

  3. Browse the Web interface for the namenode; by default it is available:
    • Namenode-Http: // localhost: 50070/
  4. Make the HDFS directories required to execute mapreduce jobs:
      $ bin/hdfs dfs -mkdir /user  $ bin/hdfs dfs -mkdir /user/<username>
  5. Copy the input files into the distributed filesystem:
      $ bin/hdfs dfs -put etc/hadoop input
  6. Run some of the examples provided:
      $ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.4.1.jar grep input output ‘dfs[a-z.]+‘
  7. Examine the output files:

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

      $ bin/hdfs dfs -get output output  $ cat output/*

    Or

    View the output files on the distributed filesystem:

      $ bin/hdfs dfs -cat output/*
  8. When you're done, stop the daemons:
      $ sbin/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.

  1. Configure parameters as follows:

    ETC/hadoop/mapred-site.xml:

    <configuration>    <property>        <name>mapreduce.framework.name</name>        <value>yarn</value>    </property></configuration>

    ETC/hadoop/yarn-site.xml:

    <configuration>    <property>        <name>yarn.nodemanager.aux-services</name>        <value>mapreduce_shuffle</value>    </property></configuration>
  2. Start ResourceManager daemon and nodemanager daemon:
      $ sbin/start-yarn.sh
  3. Browse the Web interface for the ResourceManager; by default it is available:
    • ResourceManager-Http: // localhost: 8088/
  4. Run a mapreduce job.
  5. When you're done, stop the daemons:
      $ sbin/stop-yarn.sh

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.