安装过程主要参考官方文档:

http://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/SingleCluster.html

目标:

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 ,以便使用 Hadoop MapReduce、HDFS 完成一些简单操作。

软件准备:

Ubuntu 16.04

这里使用 VMware 搭建 Ubuntu 16.04 的虚拟机系统

Hadoop 3.1.0

Hadoop 安装包下载镜像站:Apache Download Mirrors

这里下载的版本是: hadoop-3.1.0.tar.gz

解压下载的 Hadoop 压缩包:

  1. $ tar -zxvf hadoop-3.0..tar.gz

Openjdk 8.0

Version 2.7 and later of Apache Hadoop requires Java 7. It is built and tested on both OpenJDK and Oracle (HotSpot)'s JDK/JRE.

Earlier versions (2.6 and earlier) support Java 6.

Here are the known JDKs in use or which have been tested:

  • Version

    Status

    Reported By

    oracle 1.7.0_15

    Good

    Cloudera

    oracle 1.7.0_21

    Good (4)

    Hortonworks

    oracle 1.7.0_45

    Good

    Pivotal

    openjdk 1.7.0_09-icedtea

    Good (5)

    Hortonworks

    oracle 1.6.0_16

    Avoid (1)

    Cloudera

    oracle 1.6.0_18

    Avoid

    Many

    oracle 1.6.0_19

    Avoid

    Many

    oracle 1.6.0_20

    Good (2)

    LinkedIn, Cloudera

    oracle 1.6.0_21

    Good (2)

    Yahoo!, Cloudera

    oracle 1.6.0_24

    Good

    Cloudera

    oracle 1.6.0_26

    Good(2)

    Hortonworks, Cloudera

    oracle 1.6.0_28

    Good

    LinkedIn

    oracle 1.6.0_31

    Good(3, 4)

    Cloudera, Hortonworks

  1. $ sudo apt upgrade
  1. $ sudo apt install openjdk-8-jre openjdk-8-jdk

JAVA 可以使用 Oracle 的JDK 或者直接安装 OpenJDK,这里安装的是 OpenJDK 8。

可以使用 java -version 来查看 java 版本。

安装 java 之后编辑 /etc/profile ,配置 Java、Hadoop 环境变量:

  1. $ sudo vi /etc/profile
  1. # set oracle jdk 、hadoop environment
    export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
  2. export HADOOP_HOME=/home/wu/hadoop-3.1.0
  1. $ source /etc/profile

使用以下命令检查环境值:

  1. $ echo $JAVA_HOME
  2. /usr/lib/jvm/java-1.8.-openjdk-amd64
  3.  
  4. $ echo $HADOOP_HOME
  5. /home/wu/hadoop-3.1.

ssh

  1. $ sudo apt install ssh

安装过程:

Prepare to Start the Hadoop Cluster

在 hadoop 安装目录下,编辑 etc/hadoop/hadoop-env.sh 文件:

  1. export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64

可以测试一下 hadoop:

  1. $ bin/hadoop

或者:

  1. $ bin/hadoop version
  2. Hadoop 3.1.
  3. Source code repository https://github.com/apache/hadoop -r 16b70619a24cdcf5d3b0fcf4b58ca77238ccbe6d
  4. Compiled by centos on --30T00:00Z
  5. Compiled with protoc 2.5.
  6. From source with checksum 14182d20c972b3e2105580a1ad6990
  7. This command was run using /home/wu/hadoop-3.1./share/hadoop/common/hadoop-common-3.1..jar

启动 Hadoop

启动hadoop集群有三种模式:

  1. 本地(独立)模式,Local (Standalone) Mode
  2. 伪分布式模式,Pseudo-Distributed Mode
  3. 完全分布式模式、Fully-Distributed Mode

1、针对本地模式 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.

可以使用下面的一个例子简单使用 hadoop :

  1. $ mkdir input
  2. $ cp etc/hadoop/*.xml input
  3. $ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.9.1.jar grep input output 'dfs[a-z.]+'
  4. $ cat output/*

2、针对伪分布式模式 Pseudo-Distributed Mode :

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

配置环境:

  1. $ sudo vi etc/hadoop/core-site.xml
  1. <configuration>
  2. <property>
  3. <name>fs.defaultFS</name>
  4. <value>hdfs://localhost:9000</value>
  5. </property>
  6. </configuration>

$ sudo vi etc/hadoop/hdfs-site.xml

  1. <configuration>
  2. <property>
  3. <name>dfs.replication</name>
  4. <value>1</value>
  5. </property>
  6. </configuration>

设置 SSH 免密码登陆(Setup passphraseless ssh):

先测试是否能免密码登陆(Now check that you can ssh to the localhost without a passphrase):

  1. $ ssh localhost

如果需要密码才能登陆,则执行下面的命令(If you cannot ssh to localhost without a passphrase, execute the following commands):

  1. $ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
  2. $ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
  3. $ chmod ~/.ssh/authorized_keys

执行(Execution):

The following instructions are to run a MapReduce job locally.

格式化文件系统:

  1. $ bin/hdfs namenode -format

启动 namenode、datanode 守护进程:

  1. $ sbin/start-dfs.sh

  Starting namenodes on [localhost]
  Starting datanodes
  Starting secondary namenodes [ubuntu]

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

此时可以访问namenode的web服务:http://localhost:9870/,查看namenode健康状况,可以观察到有一个存活的datanode节点。

执行mapreduce任务

  1. # 在分布式文件系统中创建用户目录
  2. $ bin/hdfs dfs -mkdir /user
  3. $ bin/hdfs dfs -mkdir /user/root
  4.  
  5. # 拷贝数据到分布式文件系统中
  6. $ bin/hdfs dfs -mkdir -p input
  7. $ bin/hdfs dfs -put etc/hadoop/*.xml input
  8.  
  9. # 运行hadoop提供的mapreduce任务
  10. $ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.0.jar grep /input output 'dfs[a-z.]+'
  11.  
  12. # 拷贝任务执行结果到本地文件系统中

 $ sudo bin/hdfs dfs -mkdir -p output

 $ bin/hdfs dfs -get output output

 $ cat output/*


  1. # 或直接从分布式文件系统中查看计算结果
  2. # $ bin/hdfs dfs -cat output/*

最后,结束守护进程:

  1. $ sbin/stop-dfs.sh

Hadoop 3.1.0 在 Ubuntu 16.04 上的安装过程的更多相关文章

  1. Hadoop 3.1.0 在 Ubuntu 16.04 上安装时遇到的问题

    1.Hadoop 安装 pdsh localhost: Connection refused Hadoop安装过程中使用 $ sbin/start-dfs.sh 启动节点时,发生错误提示: pdsh@ ...

  2. Ubuntu 16.04上anaconda安装和使用教程,安装jupyter扩展等 | anaconda tutorial on ubuntu 16.04

    本文首发于个人博客https://kezunlin.me/post/23014ca5/,欢迎阅读最新内容! anaconda tutorial on ubuntu 16.04 Guide versio ...

  3. Ubuntu 16.04 Server 版安装过程图文详解

    进入系统安装的第一个界面,开始系统的安装操作.每一步的操作,左下角都会提示操作方式!! 1.选择系统语言-English 2.选择操作-Install Ubuntu Server 3.选择安装过程和系 ...

  4. 在Ubuntu 16.04 上编译安装OpenCV3.2.0(Cmake + python3 + OpenCV3)(转)

    1 安装CMAKE sudo apt-get install cmake 2 安装python及其所依赖的软件包 sudo apt-get install build-essential sudo a ...

  5. Ubuntu 16.04 LTS 降级安装GCC 4.8

    转载自https://www.linuxidc.com/Linux/2017-03/142299.htm Ubuntu 16.04 LTS 降级安装GCC 4.8 [日期:2017-03-28] 来源 ...

  6. Ubuntu 16.04系统下安装Discuz出现“HTTP ERROR 500”目前无法处理此请求

    问题:当我们在Ubuntu 16.04系统下安装Disucz X3时,修改好文件的权限,浏览器输入地址安装时出现如下图所示问题: 问题查询: 在终端输入: tail -f /var/log/apach ...

  7. Ubuntu 16.04.2 LTS 安装 jdk1.6 和 tomcat6 (一)

    java和tomcat环境配置已经有很多教程和文章,最近项目需要配置Ubuntu 16.04.2下的古老的java6和tomcat 6,遇到小坑,特记录和分享. 网上的教程不是太新,就是太老,还有一些 ...

  8. [eShopOnContainers 学习系列] - 03 - 在远程 Ubuntu 16.04 上配置开发环境

    直接把 md 粘出来了,博客园的富文本编辑器换成 markdown,没啥效果呀 ,先凑合吧.实在不行换地方   # 在远程 Ubuntu 16.04 上配置开发环境 ## 零.因 为什么要用这么麻烦的 ...

  9. Ubuntu 16.04下编译安装Apache2.4和PHP7结合

    Ubuntu 16.04下编译安装Apache2.4和PHP7结合,并安装PDOmysql扩展. 1.编译安装apache2.4.20 1 第一步: ./configure --prefix=/usr ...

随机推荐

  1. sublime text 3中emmet常用技巧

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. ValueError: option names {'--alluredir'} already added 报错

    运行测试用例 import pytest from WXP2P_2.test_data2.login_case import logindata_error1,logindata_error2,log ...

  3. MAC进入文件夹快捷键

    common + O common+up common+Down shift + common +G

  4. jquery动态实现填充下拉框

    当点下拉框时动态加载后台数据. 后台代码 protected void doPost(HttpServletRequest request, HttpServletResponse response) ...

  5. centos7 samba配置完成后不管怎么登陆都会显示密码错误的解决方案

    添加系统用户 useradd samba 添加samba用户 smbpasswd -a samba 激活samba用户 smbpasswd -e samba 1.win+r运行secpol.msc打开 ...

  6. CONTEST1001 题解

    PROBLEM A 分析 这个题属于非常基础的输出问题,一般来说见到这种题可以直接复制粘贴即可. 讲解 没有什么详细说明的直接复制粘贴即可.这样不容易出错. 代码 #include <stdio ...

  7. CentOS7服务器上部署Oracle客户端

    环境 操作系统: CentOS7.2.1511 x86_64 准备安装包 在这个网站:https://www.oracle.com/technetwork/topics/linuxx86-64soft ...

  8. 转: opencv4.0.0 +opencv_contrib在vs2015中编译

    https://blog.csdn.net/baidu_40691432/article/details/84957737

  9. luogu2312 解方程 (数论,hash)

    luogu2312 解方程 (数论,hash) 第一次外出学习讲过的题目,然后被讲课人的一番话惊呆了. 这个题,我想着当年全国只有十几个满分.....然后他又说了句我考场A这道题时,用了5个模数 确实 ...

  10. 前端上传控件plupload总结

    plupload是一个单图和多图上传控件: 属性和方法介绍,参考以下博客: https://www.cnblogs.com/2050/p/3913184.html 这里直接贴出JS代码,细到爆的注释, ...