MapReduce

一、hadoop - 创建单个节点集群

允我心安 提交于 2020-01-19 21:48:43
目的 准备工作 支持的平台 需要的软件 安装软件 下载 准备开始Hadoop集群 本地操作 伪分布式操作 配置 设置互信ssh通信 执行 YARN在单个节点 分布式操作 目的 这篇文档描述了如何创建和配置一个单一节点的hadoop,于是你可以很快地利用Hadoop的MapReduce和Hadoop的分布式文件系统(HDFS,Hadoop Distributed File System)做一些简单的操作。 准备工作 支持的平台 GNU/Linux 作为开发和生产平台都是支持的。hadoop在GNU/Linux上已经发布了2000个节点。 Windows也是一个支持的平台,但是接下来的步骤都只对于Linux平台。 需要的软件 Linux需要的软件包括: Java平台是必须安装的。 ssh必须安装,并且sshd必须运行,因为要利用它来运行Hadoop的脚本从而管理远程hadoop守护进程 安装软件 如果你的集群没有这些软件,你就需要去安装它们。 比如,在Ubuntu Linux上: $ sudo apt-get install ssh $ sudo apt-get install rsync 下载 可以从 Apache官方维护镜像文件 来下载最新的稳定的Hadoop发布版本。 准备开始Hadoop集群 将下载的hadoop进行解压。编辑文件/etc/hadoop/hadoop-env

spark shuffle

六月ゝ 毕业季﹏ 提交于 2020-01-18 14:17:15
Spark Shuffle 1. Shuffle相关 当Map 的输出结果要被Reduce使用时,输出结果需要按key哈希,并且分发到每一个Reducer上去,这个过程就是shuffle。由于shuffle涉及到了磁盘的读写和网络的传输,因此shuffle性能的高低直接影响到了整个程序的运行效率。概念上shuffle就是一个沟通数据连接(map和reduce)的桥梁。每个ReduceTask从每个Map Task产生数的据中读取一片数据,极限情况下可能触发M*R个数据拷贝通道(M是MapTask数目,R是Reduce Task数目)。 在Spark1.1 之前,其shuffle只存在一种模式,即hash base。在Spark1.1版本之后加入了sort base。Spark1.1默认采用的shuffle模式还是hash base。在Spark1.2中,sort base将作为默认模式。当然,你可以通过shuffle manager进行配置。 2. Spark shuffle流程 · 首先每一个Mapper 会根据Reducer的数量创建出相应的bucket,bucket的数量是M×R,其中M是Map的个数,R是Reduce的个数。 · 其次Mapper 产生的结果会根据设置的partition算法填充到每个bucket中去。这里的partition算法是可以自定义的

MapReduce: DistributedCache的使用例子

南楼画角 提交于 2020-01-18 01:11:17
需求场景: 过滤无意义的单词后再进行文本词频统计。处理流程是: 1)预定义要过滤的无意义单词保存成文件,保存到HDFS中; 2)程序中将该文件定位为作业的缓存文件,使用DistributedCache类; 3)Map中读入缓存文件,对文件中的单词不做词频统计。 该场景主要解决文件在Hadoop各task之间共享的问题,用conf传递参数不能传输大文件,于是通过DistributedCache派发文件到各节点。 java 例子如下 package com.word; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.net.URI; import java.util.HashSet; import java.util.StringTokenizer; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job;

Hadoop MapReduce Shuffle 详解

孤街醉人 提交于 2020-01-17 17:04:49
一、什么是Shuffle机制 在MapReduce中,shuffle更像是洗牌的逆过程,指的是将map端的无规则输出按指定的规则“打乱”成具有一定规则的数据,以便reduce端接收处理。其在MapReduce中所处的工作阶段是 map输出后到reduce接收前 ,具体可以分为map端和reduce端前后两个部分。在shuffle之前,也就是在map阶段,MapReduce会对要处理的数据进行分片(split)操作,为每一个分片分配一个MapTask任务。接下来 map()函数会对每一个分片中的每一行数据进行处理得到键值对(key,value),其中key为偏移量,value为一行的内容 。此时得到的键值对又叫做“中间结果”。此后便进入shuffle阶段,由此可以看出shuffle阶段的作用是处理“中间结果”,Shuffle机制是整个MapReduce框架中最核心的部分。 二、Shuffle的执行阶段流程 上图是官方对Shuffle过程的描述,通过图片我们可以大致的了解到Shuffle的工作流程。Shuffle并不是Hadoop的一个组件,只是map阶段产生数据输出到reduce阶段取得数据作为输入之前的一个过程。 所以Shuffle阶段应该分为map之后( map的shuffle阶段 )以及 reduce之前( reduce的shuffle阶段 ),如下图所示: 1

hadoop streaming: where are application logs?

随声附和 提交于 2020-01-17 14:06:50
问题 My question is similar to : hadoop streaming: how to see application logs? (The link in the answer is not currently working. So I have to post it again with an additional question) I can see all hadoop logs on my /usr/local/hadoop/logs path but where can I see application level logs? for example : reducer.py - import logging .... logging.basicConfig(level=logging.ERROR, format='MAP %(asctime)s%(levelname)s%(message)s') logging.error('Test!') ... I am not able to see any of the logs (WARNING

How to process a list of complex data structures

醉酒当歌 提交于 2020-01-17 14:01:04
问题 In High Charts i have an array as follows, But if i try to set extremes of the chart by returning the Highest value of the Array, its showing NaN Error. function aoDashboardData() { var data = [ { type: "", data: [{ x: 0.0, low: Date.UTC(2016, 2, 15), high: Date.UTC(2016, 4, 10), color: "#4B0081" }, { x: 0.0, low: Date.UTC(2016, 4, 15), high: Date.UTC(2016, 6, 15), color: "#00BFFE" }, { x: 0.0, low: Date.UTC(2016, 6, 20), high: Date.UTC(2016, 8, 0), color: "#0047AB" }, { x: 0.0, low: Date.UTC

regarding the Hive commands that do not invoke underlying MapReduce jobs

倖福魔咒の 提交于 2020-01-17 12:10:12
问题 My understanding is that Hive is an SQL-like language that can perform database-related tasks by invoking underlying MapReduce programs. However, I learned that some Hive commands does not invoke MapReduce job. I am curious to know that what are these commands, and why they do not need to invoke MapReduce job. 回答1: You are right, Hive uses MR jobs on the background to process the data. Wen you fire a SQL like query in hive, it converts it into various MR jobs on the background and gives you

HDFS - Block Size Related

这一生的挚爱 提交于 2020-01-17 06:07:28
问题 I have files of 10 MB size only.I think in HDFS first file consumes 10 MB and rest 54 MB is freed up to ad to the available space. My question is - The second file of 10 MB (or the next sequence of 10 MB files) would keep on adding to this until it becomes 64 MB? For e.g. -In total if we consume 2 blocks of 64 MB each and 20 MB of 3rd block, then the input split will give 3 outputs 2 64MB and 1 20MB ? Is it true? 回答1: With Reference from Hadoop - The Definitive Guide : HDFS stores small files

HDFS - Block Size Related

蹲街弑〆低调 提交于 2020-01-17 06:06:04
问题 I have files of 10 MB size only.I think in HDFS first file consumes 10 MB and rest 54 MB is freed up to ad to the available space. My question is - The second file of 10 MB (or the next sequence of 10 MB files) would keep on adding to this until it becomes 64 MB? For e.g. -In total if we consume 2 blocks of 64 MB each and 20 MB of 3rd block, then the input split will give 3 outputs 2 64MB and 1 20MB ? Is it true? 回答1: With Reference from Hadoop - The Definitive Guide : HDFS stores small files

DistributedCache in Hadoop 2.x

我的梦境 提交于 2020-01-17 04:43:05
问题 I have a problem in DistributedCache in Hadoop 2.x the new API, I found some people working around this issue, but it does not solve my problem example this solution does not work with me Because i got a NullPointerException when trying to retrieve the data in DistributedCache My Configuration is as follows: Driver public int run(String[] arg) throws Exception { Configuration conf = this.getConf(); Job job= new Job(conf,"job Name"); ... job.addCacheFile(new URI(arg[1]); Setup protected void