MapReduce

Similar documents
雲端 Cloud Computing 技術指南 運算 應用 平台與架構 10/04/15 11:55:46 INFO 10/04/15 11:55:53 INFO 10/04/15 11:55:56 INFO 10/04/15 11:56:05 INFO 10/04/15 11:56:07 INFO


Java ¿ª·¢ 2.0: Óà Hadoop MapReduce ½øÐдóÊý¾Ý·ÖÎö

Hadoop 集 群 ( 第 6 期 ) WordCount 运 行 详 解 1 MapReduce 理 论 简 介 1.1 MapReduce 编 程 模 型 MapReduce 采 用 分 而 治 之 的 思 想, 把 对 大 规 模 数 据 集 的 操 作, 分 发 给 一 个 主 节 点 管

使用MapReduce读取XML文件

2/80 2

CC213

chp6.ppt

投影片 1

<4D F736F F F696E74202D20C8EDBCFEBCDCB9B9CAA6D1D0D0DEBDB2D7F92E707074>

EJB-Programming-4-cn.doc

目次 

PowerPoint 演示文稿

tar -xzf hadoop tar.gz mv hadoop /app 在 Hadoop 目录下创建子目录 在 hadoop 目录下创建 tmp name 和 data 目录 cd /app/hadoop mkdir tmp mkdir

Learning Java

培 训 机 构 介 绍 中 科 普 开 是 国 内 首 家 致 力 于 IT 新 技 术 领 域 的 领 航 者, 专 注 于 云 计 算 大 数 据 物 联 网 移 动 互 联 网 技 术 的 培 训, 也 是 国 内 第 一 家 开 展 Hadoop 云 计 算 的 培

Improved Preimage Attacks on AES-like Hash Functions: Applications to Whirlpool and Grøstl

epub83-1

C10_ppt.PDF

Chapter 9: Objects and Classes

Windows XP

1: public class MyOutputStream implements AutoCloseable { 3: public void close() throws IOException { 4: throw new IOException(); 5: } 6:

ABOUT ME AGENDA 唐建法 / TJ MongoDB 高级方案架构师 MongoDB 中文社区联合发起人 Spark 介绍 Spark 和 MongoDB 案例演示

EJB-Programming-3.PDF

untitled

Microsoft PowerPoint - STU_EC_Ch08.ppt

Reducing Client Incidents through Big Data Predictive Analytics

201316

untitled

Microsoft Word - 11月電子報1130.doc

业 务 与 运 营 Business & Operation (Transform) 加 载 (Load) 至 目 的 端 的 过 程, 该 部 分 在 数 据 挖 掘 和 分 析 过 程 中 为 最 基 础 的 一 部 分 一 个 良 好 的 ETL 系 统 应 该 有 以 下 几 个 功 能 1

COCO18-DensePose-BUPT-PRIV

The Development of Color Constancy and Calibration System

VASP应用运行优化

EK-STM32F

目录 1 编译 HADOOOP 搭建环境 安装并设置 maven 以 root 用户使用 yum 安装 svn 以 root 用户使用 yum 安装 autoconf automake libtool cmake..

JavaIO.PDF

第 15 章 程 式 編 写 語 言 15.1 程 式 編 写 語 言 的 角 色 程 式 編 寫 語 言 是 程 式 編 寫 員 與 電 腦 溝 通 的 界 面 語 法 是 一 組 規 則 讓 程 式 編 寫 員 將 字 詞 集 合 起 來 電 腦 是 處 理 位 元 和 字 節 的 機 器, 與

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

D C 93 2

目录 1 本期内容 MapReduce 理论简介 MapReduce 编程模型 MapReduce 处理过程 运行 WordCount 程序 准备工作 运行例子

三种方法实现Hadoop(MapReduce)全局排序(1)

Hadoop_Jordan

穨control.PDF

Process Data flow Data store External entity 6-10 Context diagram Level 0 diagram Level 1 diagram Level 2 diagram

mvc

IP TCP/IP PC OS µclinux MPEG4 Blackfin DSP MPEG4 IP UDP Winsock I/O DirectShow Filter DirectShow MPEG4 µclinux TCP/IP IP COM, DirectShow I

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile..

关于天云趋势 天云趋势由宽带资本和趋势科技共同投资成立于 2010 年 3 月 趋势科技是 Hadoop 的重度使用者 : 2006 年开始使用, 用于处理网页和邮件服务器评级 五个数据中心, 近 1000 个节点, 最大集群约 500 台服务器 日均处理 3.6T 日志数据 亚洲最早, 也是最大的

A Preliminary Implementation of Linux Kernel Virus and Process Hiding

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO

92 (When) (Where) (What) (Productivity) (Efficiency) () (2) (3) (4) (5) (6) (7) em-plant( SiMPLE++) Scheduling When Where Productivity Efficiency [5]

在Fedora上部署Hadoop2.2.0伪分布式平台

ebook140-8

Outline Speech Signals Processing Dual-Tone Multifrequency Signal Detection 云南大学滇池学院课程 : 数字信号处理 Applications of Digital Signal Processing 2

2013_6_3.indd

ebook140-9

Oracle 4

目录 1 本期内容 Hadoop 开发环境简介 Hadoop 集群简介 Windows 开发简介 Hadoop Eclipse 简介和使用 Eclipse 插件介绍 Hadoo

PowerPoint 演示文稿

自由軟體教學平台


(baking powder) 1 ( ) ( ) 1 10g g (two level design, D-optimal) 32 1/2 fraction Two Level Fractional Factorial Design D-Optimal D

提纲 1 2 OS Examples for 3

(TestFailure) JUnit Framework AssertionFailedError JUnit Composite TestSuite Test TestSuite run() run() JUnit

K7VT2_QIG_v3

目 录 1 不 断 开 发 工 具 以 管 理 大 数 据 Hadoop* 简 介 : 支 持 从 大 数 据 中 获 得 出 色 价 值 的 可 靠 框 架 大 数 据 技 术 的 行 业 生 态 系 统 在 关 键 组 件 中 实 现 平 衡...


1.JasperReport ireport JasperReport ireport JDK JDK JDK JDK ant ant...6

软件测试(TA07)第一学期考试

Microsoft Word htm

Microsoft PowerPoint - Performance Analysis of Video Streaming over LTE using.pptx

UDC 厦门大学博硕士论文摘要库

untitled

ebook39-6


Microsoft PowerPoint - Aqua-Sim.pptx

CH01.indd

IT Data-intensive application,iscsi Middl

Cloudy computing forEducation

參 加 第 二 次 pesta 的 我, 在 是 次 交 流 營 上 除 了, 與 兩 年 沒 有 見 面 的 朋 友 再 次 相 聚, 加 深 友 誼 外, 更 獲 得 與 上 屆 不 同 的 體 驗 和 經 歴 比 較 起 香 港 和 馬 來 西 亞 的 活 動 模 式, 確 是 有 不 同 特

Outline USB Application Requirements Variable Definition Communications Code for VB Code for Keil C Practice


BC04 Module_antenna__ doc

Cadence SPB 15.2 VOICE Cadence SPB 15.2 PC Cadence 3 (1) CD1 1of 2 (2) CD2 2of 2 (3) CD3 Concept HDL 1of 1

编写简单的Mapreduce程序并部署在Hadoop2.2.0上运行

Abstract arm linux tool-chain root NET-Start! 2

三种方法实现Hadoop(MapReduce)全局排序(2)

9, : Java 19., [4 ]. 3 Apla2Java Apla PAR,Apla2Java Apla Java.,Apla,,, 1. 1 Apla Apla A[J ] Get elem (set A) A J A B Intersection(set A,set B) A B A B

白 皮 书 英 特 尔 IT 部 门 实 施 Apache Hadoop* 英 特 尔 分 发 版 软 件 的 最 佳 实 践 目 录 要 点 概 述...1 业 务 挑 战...2 Hadoop* 分 发 版 注 意 事 项...3 Hadoop* 基 础 架 构 注 意 事 项

untitled

coverage2.ppt

1 C++ 2 Bjarne Stroustrup C++ (system programming) 6 (infrastructure) C++ 7 Herb Sutter 8 C++ (efficiency) (flexibility) 9 (abstraction) (productivity

Microsoft Word - 11.doc

Guide to Install SATA Hard Disks

場 的 職 能 需 求 狀 況, 並 能 有 一 套 職 能 管 理 資 訊 系 統 對 各 職 位 進 行 職 能 資 料 管 理 分 析 與 應 用 資 料, 則 對 企 業 人 力 應 用 與 提 昇 上 均 有 極 大 之 助 益, 故 本 研 究 之 主 要 目 的 有 二 : (1) 職

untitled

Chapter 2

Some experiences in working with Madagascar: installa7on & development Tengfei Wang, Peng Zou Tongji university

(Electronic Data Interchange) (Executive Information System) (Economic Order Quantity) (Enterprise Resource Planning) (Flexible Manufacture System) (F

Transcription:

MapReduce 陳威宇

Review Hadoop Hdfs Datanode Namenode files / blocks Data locality ( 在地運算 ) 2

Outline What is MapReduce Process flow Yarn Configuration Java programing 3

MapReduce Introduction Objective : Design scalable parallel programming framework to be deployed on large cluster of commodity machines Data divided into splits, each processed by map functions, whose output are processed by reduce functions. Originated and first practical implementation in Google Inc. 2004 4

運算篇 ( MapReduce) 儲存篇 ( HDFS ) Hadoop 1.X 遇到的挑戰 我們希望 事實上 無論大小, 通通進 hdfs 資料可以任意修改 生產在用, 當然要 High Availability 多種用法 圖形運算 及時運算 資源分配更精確更廣泛 一個 namenode 管理資料的定址空間有限 檔案無法再修改 Single Point Of Failure 只有 batch job 文字處理 每個 batch job 都需讀所有的資料 一起處理 只有一種用法 : Map -> Reduce 5

Yarn = MapReduce V2 Yarn 與 MapReduce V1 相同之處 編程模型 :map() 與 reduce() MRv1 與 MRv2 的程式寫法都相同 但需要用 V2 框架重新 compiler 6

Yarn = MapReduce V2 Yarn 與 MapReduce V1 相異之處 運算環境 : MRv1: 只有 map / reducer 兩種 slot MRv2:container 可以運算各種型態的程序 資源管理 : MRv1: 所有工作統籌都交給 JobTracker ( 經理 / 工程師 ) MRv2:ResourceManager 管資源,ApplicationMaster 管工作 ( 經理 /PI/ 工程師 ) 7

YARN 運作模式 1. Client 向 RM 提交工作 2. RM 啟動挑選一個 container 啟動 AM 3. AM 啟動後會向 RM 註冊 4. AM 向 RM 協商 container 資源使用 5. 協商成功後,AM 可以向 NM 要求 container 資源 6. 接著 program 會在 NM 上的 container 上做計算 7. 運算期間,client 可以直接與 AM 溝通, 取得 job 資訊 8. 一旦程式運算完成, AM 會向 RM 申請註銷, 並釋放自身的 container 資源 8

還有更威的 : Spark 天下武功 唯快不破 Run programs up to 100x faster than Hadoop MapReduce in memory, or 10x faster on disk. 理由 : RDD (Resilient Distribute Datasets) In memory 適用場景 迭代式運算 交互分析 Why not 不夠穩定 不夠 bigdata 9

At a glance 10

Why MapReduce 11

The Feature Distributed Computing Fault tolerance Task granularity Data locality 12

Distributed Computing Figure source: https://www.cs.rutgers.edu/~pxk/417/notes/content/mapreduce.html 13

Fault tolerance Objective : handle machine failures gracefully, i.e. programmer don t need to handle it or be aware of details. Two type of failures : Master failure Worker failure Two main activities Failure detection Recover lost (computed) data with least possible cost 14

Task granularity Load balancing: fine grained is better, faster machines tend to take more tasks than slower machined over time, leads to less overall job execution time. Failure recovery : less time to re-execute failed tasks. Very fine-grained tasks may not be desirable : overhead to manage and too much data shuffling (consume valuable bandwidth). Optimal Granularity : Split size = HDFS block size (128 MB by default) HDFS block is guaranteed to be in the same node. We need to maximize work done by one mapper locally if split size < block : not fully utilizing possibility of local data processing if split size > block : may need data transfer to make map function complete Where s the catch? Less expensive to make more mappers than moving data, code size is far less than data size. Practical considerations Master bottleneck : take O(M+R) scheduling decision, and store O(M*R) states. # mappers = Input file size / file system block size (16 to 128 MB) 15

Data locality Network bandwidth is a valuable resource. We assume a rack server hardware. MapReduce scheduler works as follows : 1. Try to assign map task to the node where the corresponding split block(s) reside, if it is free assign, else go to step 2 2. try to find a free nod in the same rack to assign the map task, if can t find a free offrack node to assign. More complex implementation uses network cost model. 16

MapReduce Process Flow 17

Example 18

Example 19

Example 20

Map 21

Shuffle & Sort Map -> Sort -> Shuffle -> Sort -> Reduce 開發人員不用煩腦,framework 會自行處理 確保所有 key1 的值一定在同一個 Reducer 裡出現 22

Reduce 23

Yarn Setup 24

Yarn Installation & Configuration yarn-site.xml mapred-site.xml <configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration> <configuration><property> <name>yarn.resourcemanager.scheduler.address</name> <value>master:8030</value> </property><property> <name>yarn.resourcemanager.resource-tracker.address</name> <value>master:8031</value> </property><property> <name>yarn.resourcemanager.address</name> <value>master:8032</value> </property><property> <name>yarn.nodemanager.address</name> <value>0.0.0.0:8034</value> </property><property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property><property> <name>yarn.nodemanager.local-dirs</name> <value>/home/hadoop/hadoop_dir/nm-local-dir</value> </property><property> <name>yarn.nodemanager.log-dirs</name> <value>/home/hadoop/hadoop_dir/userlogs</value> </property></configuration> 25

環境 conf / yarn.site.xml: conf / mapred.site.xml: conf/slaves: master slave master x.x.x.1 Namenode Resource Manager Datanode Node Manager http://x.x.x.1:50070 http://x.x.x.1:8088 slave x.x.x.2 Datanode Node Manager 26

YARN CLI 啟動與關閉 YARN 確認 HDFS 已啟動 $start-yarn.sh $stop-yarn.sh 確認 ResourceManager 與 NodeManager 皆啟動 JPS http://master:8088/cluster Run mr example In /home/hadoop/hadoop/share/hadoop/mapreduce hadoop jar hadoop-mapreduce-examples-2.5.0- cdh5.3.2.jar pi 10 1000 27

MapReduce Programming Model 28

Java programming Programing prototype public class MyMR { public class MyMapper extends Mapper<Object, Text, Text, IntWritable> { }... Map Code public class MyReducer extends Reducer<Text, IntWritable, Text, IntWritable> { Reduce Code }... } public static void main(string[] args) throws Exception { } Driver Code 29

Java programming Driver Driver Code Configuration conf = new Configuration(); Job job = new Job(conf, New MR job"); job.setjarbyclass(mymr.class); job.setmapperclass(mymapper.class); job.setreducerclass(myreducer.class); job.setoutputkeyclass(text.class); job.setoutputvalueclass(intwritable.class); FileInputFormat.addInputPath(job, new Path(otherArgs[0])); FileOutputFormat.setOutputPath(job, new Path(otherArgs[1])); System.exit(job.waitForCompletion(true)? 0 : 1); Config Initialize Job Initialize Job setup Input / output setup Job run 30

Java programming Driver / input & output format Input / Output Format 設定 若使用預設的 input/output format TextInputFormat/TextOutputFormat, 無需在 Driver 中設定 每一筆結果為輸出文件中的一行 每一行包含 key/value, 預設以 tab 分隔 Key/value 可為任意 class, 但需在 Driver 中設定 若使用非預設的 input/output format job.setinputformatclass(sequencefileinputformat.class ); job.setoutputformatclass(nulloutputformat.class); 31

Java programming Driver / input & output format Input / Output Format 設定 若使用預設的 input/output format TextInputFormat/TextOutputFormat, 無需在 Driver 中設定 每一筆結果為輸出文件中的一行 每一行包含 key/value, 預設以 tab 分隔 Key/value 可為任意 class, 但需在 Driver 中設定 若使用非預設的 input/output format job.setinputformatclass(sequencefileinputformat.class ); job.setoutputformatclass(nulloutputformat.class); 32

Java programming Mapper 33

Java programming Mapper / Realcase public class WordCountMapper extends Mapper< Object, Text, Text, IntWritable>{ public void map(object key, Text value, Context context ) throws IOException, InterruptedException { StringTokenizer itr = new StringTokenizer(value.toString()); IntWritable one = new IntWritable(1); } } while (itr.hasmoretokens()) { Text word = new Text(itr.nextToken()) context.write(word, one); } 34

Java programming Reducer 35

Java programming Reducer / Realcase public class WordCountReducer extends Reducer< Text, IntWritable, Text, IntWritable > { public void reduce( Text key, Iterable< IntWritable > values, Context context) throws IOException, InterruptedException { int sum = 0; IntWritable result = new IntWritable(); for (IntWritable val : values) { sum += val.get(); } } result.set(sum); context.write(key, result); } 36