hadoop官网翻译第二天Setting up a Single Node Cluster.

如有不对的地方,请大家指出,共同进步

Getting Started

The Hadoop documentation(文档) includes the information you need to get started using Hadoop. Begin with the Single Node Setup which shows you how to set up a single-node Hadoop installation(安装). Then move on to the Cluster Setup to learn how to set up a multi-node Hadoop installation.

hadoop文档包含开始使用Hadoop的信息。开始是单节点的安装,教你hadoop单节点的安装方法,然后是集群安装,教你学习,多节点hadoop的安装。

 

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

本文档描述了,怎样去建立并且配置一个单节点hadoop的安装,这样你可以使用MR和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.

支持GNU/Linux作为开发和生产平台。Hadoop已经在具有2000个节点的GNU/Linux集群上进行了演示。

 Windows也是一个受支持的平台,但是下面的步骤只针对Linux。要在Windows上设置Hadoop,请参阅wiki页面。

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.

在linux所需要的软件

1、java必须被安装,在HadoopJavaVersions中查看了适合的java版本

2、必需安装ssh,sshd必须运行以使用Hadoop脚本管理远程Hadoop守护进程。

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

如果你的集群没有安装所需的软件,你需要安装它

例如在 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.

 要获得Hadoop发行版,请从Apache下载镜像下载一个最新的稳定版本

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:

  # set to the root of your Java installation
  export JAVA_HOME=/usr/java/latest

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:

解压缩下载的Hadoop发行版。在分发版中,编辑文件etc/hadoop/hadoop-env.sh以定义以下一些参数:

# set to the root of your Java installation
  export JAVA_HOME=/usr/java/latest

尝试以下命令:

 $ bin/hadoop

这个会显示hadoop脚本的使用文档

现在,您已经准备好在三种支持的模式之一中启动Hadoop集群

  • Local (Standalone) Mode
  • 单机模式:默认情况下运行为一个单独机器上的独立Java进程,主要用于调试环境
  • Pseudo-Distributed Mode
  • 伪分布模式:在单个机器上模拟成分布式多节点环境,每一个Hadoop守护进程都作为一个独立的Java进程运行
  • 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.9.2.jar grep input output 'dfs[a-z.]+'
  $ cat output/*

默认情况下,Hadoop被配置为在非分布式模式下运行,作为单个Java进程。这对于调试很有用。

下面的示例复制未打包的conf目录作为输入,然后查找并显示给定正则表达式的每个匹配。输出被写入给定的输出目录。

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.

Hadoop还可以在一个伪分布式模式的单个节点上运行,其中每个Hadoop守护进程在单独的Java进程中运行。

Configuration

Use the following:

使用以下方法:

etc/hadoop/core-site.xml:

<configuration>
    <property>
        <name>fs.defaultFS</name>
        <value>hdfs://localhost:9000</value>
    </property>
</configuration>

常用配置项说明:

  • fs.defaultFS这是默认的HDFS路径。当有多个HDFS集群同时工作时,用户在这里指定默认HDFS集群,该值来自于hdfs-site.xml中的配置。

  • fs.default.name这是一个描述集群中NameNode结点的URI(包括协议、主机名称、端口号),集群里面的每一台机器都需要知道NameNode的地址。DataNode结点会先在NameNode上注册,这样它们的数据才可以被使用。独立的客户端程序通过这个URI跟DataNode交互,以取得文件的块列表。

  • hadoop.tmp.dir 是hadoop文件系统依赖的基础配置,很多路径都依赖它。如果hdfs-site.xml中不配置namenode和datanode的存放位置,默认就放在/tmp/hadoop-${user.name}这个路径中。

更多说明请参考core-default.xml,包含配置文件所有配置项的说明和默认值。

 

etc/hadoop/hdfs-site.xml:

<configuration>
    <property>
        <name>dfs.replication</name>
        <value>1</value>
    </property>
</configuration>

常用配置项说明:

  • fs.defaultFS这是默认的HDFS路径。当有多个HDFS集群同时工作时,用户在这里指定默认HDFS集群,该值来自于hdfs-site.xml中的配置。

  • fs.default.name这是一个描述集群中NameNode结点的URI(包括协议、主机名称、端口号),集群里面的每一台机器都需要知道NameNode的地址。DataNode结点会先在NameNode上注册,这样它们的数据才可以被使用。独立的客户端程序通过这个URI跟DataNode交互,以取得文件的块列表。

  • hadoop.tmp.dir 是hadoop文件系统依赖的基础配置,很多路径都依赖它。如果hdfs-site.xml中不配置namenode和datanode的存放位置,默认就放在/tmp/hadoop-${user.name}这个路径中。

更多说明请参考core-default.xml,包含配置文件所有配置项的说明和默认值。

 

Setup passphraseless ssh

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

现在检查是否可以在没有密码的情况下ssh到本地主机:

  $ ssh localhost

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

如果没有密码无法ssh到localhost,请执行以下命令:

  $ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
  $ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
  $ chmod 0600 ~/.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.

以下说明将在本地运行MapReduce作业。如果您想在YARN上执行作业,请参阅单节点上运行YARN。 

       在使用hadoop前,必须格式化一个全新的HDFS安装,通过创建存储目录和NameNode持久化数据结构的初始版本,格式化         过程创建了一个空的文件系统。由于NameNode管理文件系统的元数据,而DataNode可以动态的加入或离开集群,因此这个     格式化过程并不涉及DataNode。同理,用户也无需关注文件系统的规模。集群中DataNode的数量决定着文件系统的规模。   DataNode可以在文件系统格式化之后的很长一段时间内按需增加。

  1. Format the filesystem:

      $ bin/hdfs namenode -format
    
  2. Start NameNode daemon and DataNode daemon:

    启动hdfs守护进程,分别启动NameNode和DataNode

      $ sbin/start-dfs.sh
    

    hadoop守护进程日志输出被写入$HADOOP_LOG_DIR目录(默认为$HADOOP_HOME/logs)。 

    The hadoop daemon log output is written to the $HADOOP_LOG_DIR directory (defaults to $HADOOP_HOME/logs).

  3. Browse the web interface for the NameNode; by default it is available at:

    • 浏览用于NameNode的网络接口;默认情况下,可以在:NameNode - http://localhost:50070/
  4. Make the HDFS directories required to execute MapReduce jobs:

     创建执行MapReduce作业所需的HDFS目录:

      $ 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.9.2.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 with:

    完成后,使用以下命令停止守护进程: 

      $ sbin/stop-dfs.sh

YARN on a 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.

您可以通过设置一些参数并运行ResourceManager守护进程和NodeManager守护进程,在伪分布式模式下在YARN上运行MapReduce作业。

         运行MapReduce作业。

  1. Configure parameters as follows:etc/hadoop/mapred-site.xml:

    <configuration>
        <property>
            <name>mapreduce.framework.name</name>
            <value>yarn</value>
        </property>
    </configuration>
    mapred.job.trackerJobTracker的主机(或者IP)和端口。
    更多说明请参考mapred-default.xml,包含配置文件所有配置项的说明和默认值
    

    etc/hadoop/yarn-site.xml:

    <configuration>
        <property>
            <name>yarn.nodemanager.aux-services</name>
            <value>mapreduce_shuffle</value>
        </property>
    </configuration>
    

    常用配置项说明:

    yarn.nodemanager.aux-services通过该配置,用户可以自定义一些服务
    更多说明请参考yarn-default.xml,包含配置文件所有配置项的说明和默认值

  2. Start ResourceManager daemon and NodeManager daemon:

     启动ResourceManager守护进程和NodeManager守护进程:

      $ sbin/start-yarn.sh
    
  3. Browse the web interface for the ResourceManager; by default it is available at:

     浏览ResourceManager的网页界面;默认情况下,可以在:

    ResourceManager - http://localhost:8088/
  4. Run a MapReduce job.

  5. When you’re done, stop the daemons with:

     完成后,使用以下命令停止守护进程:

      $ sbin/stop-yarn.sh

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值