Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo

1

Hadoop 与数据分析 淘宝数据平台及产品部基础研发组  周敏 日期: 2010-05-26

2

Outline Hadoop 基本概念 Hadoop 的应用范围 Hadoop 底层实现原理 Hive 与数据分析 Hadoop 集群管理 典型的 Hadoop 离线分析系统架构 常见问题及解决方案

3

关于打扑克的哲学

4

打扑克与 MapReduce Input split  shuffle  output  分牌 各自齐牌 交换 再次理牌 搞定

5

统计单词数 The weather  is good This guy is a good man Today  is good Good man is good the  1 weather  1 is  1 good  1 today 1 is  1 good  1 this  1 guy  1 is  1 a  1 good  1 man  1 good  1 man  1 is  1 good  1 a 1  good  1 good  1 good  1 good  1 good  1 man 1 man 1 the  1 weather 1 today  1 guy 1 is  1 is  1 is  1 is  1 this 1 a  1 good  5 guy  1 is  4 man  2 the  1 this  1 today  1 weather  1

6

流量计算

7

趋势分析 http://www.trendingtopics.org/ 截图

8

用户推荐

9

分布式索引

10

Hadoop  核心 Hadoop Common 分布式文件系统 HDFS MapReduce 框架 并行数据分析语言 Pig  列存储 NoSQL 数据库  Hbase 分布式协调器 Zookeeper 数据仓库 Hive( 使用 SQL) Hadoop 日志分析工具 Chukwa Hadoop 生态系统

11

Hadoop 实现 Data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Results Data data data data Data data data data Data data data data Data data data data Data data data data Data data data data Data data data data Data data data data Data data data data Hadoop Cluster DFS Block 1 DFS Block 1 DFS Block 2 DFS Block 2 DFS Block 2 DFS Block 1 DFS Block 3 DFS Block 3 DFS Block 3 MAP MAP MAP Reduce

12

 

13

作业执行流程

14

// MapClass1 中的 map 方法   public void map(LongWritable Key, Text value, OutputCollector<Text,  Text> output, Reporter reporter) throws IOException   { String strLine = value.toString(); String[] strList = strLine.split(&quot;amp;quot;&quot;); String mid = strList[3]; String  sid  = strList[4]; String timestr = strList[0]; try{   timestr = timestr.substring(0,10); }catch(Exception e){return;} timestr += &quot;0000&quot;; //  省略数十行 output.collect(new Text(mid + “” + “sid” + timestr , ...); } Hadoop 案例 (1)

15

public static class Reducer1 extends MapReduceBase implements Reducer<Text, Text, Text, Text> { private Text word = new Text(); private Text str = new Text(); public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String[] t = key.toString().split(&quot;amp;quot;&quot;); word.set(t[0]);// str.set(t[1]); output.collect(word,str);//uid kind }//reduce }//Reduce0b   Hadoop 案例 (2)

16

public static class MapClass2 extends MapReduceBase implements Mapper<LongWritable, Text, Text, Text> { private Text word = new Text(); private Text str = new Text(); public void map(LongWritable Key, Text value, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String strLine = value.toString(); String[] strList = strLine.split(&quot;s+&quot;); word.set(strList[0]); str.set(strList[1]); output.collect(word,str); } } Hadoop 案例 (3)

17

public static class Reducer2 extends MapReduceBase implements Reducer<Text, Text, Text, Text> { private Text word = new Text(); private Text str = new Text(); public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { while(values.hasNext()) { String t = values.next().toString(); //  省略数十行代码 } //  省略数十行代码 output.collect(new Text(mid + “” + sid + “”) + ...., ...) } Hadoop 案例 (4)

18

B A D A A C B C B C D Group Co-group Function Aggregate   Filter Filter Thinking in MapReduce(1)

19

Thinking in MapReduce(2)

20

Magics of Hive: SELECT COUNT(DISTINCT mid) FROM log_table Hive 的魔力

21

为什么淘宝采用 Hadoop? webalizer awstat  般若 Atpanel 时代 日志最高达 250GB/ 天 最高达约 50 道作业 每天运行 20 小时以上 Hadoop 时代 当前日志 470GB/ 天 当前 366 道作业 平均 6~7 小时完成

22

还有谁在用 Hadoop? 雅虎北京全球软件研发中心 中国移动研究院 英特尔研究院 金山软件 百度 腾讯 新浪 搜狐 IBM Facebook Amazon Yahoo!

23

Web Servers Log Collection Servers Filers Data Warehousing on  a Cluster Oracle RAC Federated MySQL Web 站点的典型 Hadoop 架构

24

淘宝 Hadoop 与 Hive 的使用 Hadoop Rich Client MetaStore  Server Mysql Scheduler Thrift Server Web JobClient CLI/GUI Client Program Web Server

25

标准输出 , 标准出错 Web 显示 (50030, 50060, 50070) NameNode,JobTracker, DataNode, TaskTracker 日志 本地重现 :  Local Runner DistributedCache 中放入调试代码 调试

26

目的:查性能瓶颈,内存泄漏,线程死锁等 工具:  jmap, jstat, hprof,jconsole, jprofiler mat,jstack 对 JobTracker 的 Profile 对各 slave 节点 TaskTracker 的 Profile 对各 slave 节点某 Child 进程的 Profile( 可能存在单点执行速度过慢 ) Profiling

27

目的:监控集群或单个节点 I/O,  内存及 CPU 工具:  Ganglia 监控

28

如何减少数据搬动 ?

29

数据倾斜

30

 

More Related Content

Hadoop与数据分析

  • 2. Outline Hadoop 基本概念 Hadoop 的应用范围 Hadoop 底层实现原理 Hive 与数据分析 Hadoop 集群管理 典型的 Hadoop 离线分析系统架构 常见问题及解决方案
  • 4. 打扑克与 MapReduce Input split shuffle output 分牌 各自齐牌 交换 再次理牌 搞定
  • 5. 统计单词数 The weather is good This guy is a good man Today is good Good man is good the 1 weather 1 is 1 good 1 today 1 is 1 good 1 this 1 guy 1 is 1 a 1 good 1 man 1 good 1 man 1 is 1 good 1 a 1 good 1 good 1 good 1 good 1 good 1 man 1 man 1 the 1 weather 1 today 1 guy 1 is 1 is 1 is 1 is 1 this 1 a 1 good 5 guy 1 is 4 man 2 the 1 this 1 today 1 weather 1
  • 10. Hadoop 核心 Hadoop Common 分布式文件系统 HDFS MapReduce 框架 并行数据分析语言 Pig 列存储 NoSQL 数据库 Hbase 分布式协调器 Zookeeper 数据仓库 Hive( 使用 SQL) Hadoop 日志分析工具 Chukwa Hadoop 生态系统
  • 11. Hadoop 实现 Data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Data data data data data Results Data data data data Data data data data Data data data data Data data data data Data data data data Data data data data Data data data data Data data data data Data data data data Hadoop Cluster DFS Block 1 DFS Block 1 DFS Block 2 DFS Block 2 DFS Block 2 DFS Block 1 DFS Block 3 DFS Block 3 DFS Block 3 MAP MAP MAP Reduce
  • 12.  
  • 14. // MapClass1 中的 map 方法 public void map(LongWritable Key, Text value, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String strLine = value.toString(); String[] strList = strLine.split(&quot;amp;quot;&quot;); String mid = strList[3]; String sid = strList[4]; String timestr = strList[0]; try{ timestr = timestr.substring(0,10); }catch(Exception e){return;} timestr += &quot;0000&quot;; // 省略数十行 output.collect(new Text(mid + “” + “sid” + timestr , ...); } Hadoop 案例 (1)
  • 15. public static class Reducer1 extends MapReduceBase implements Reducer<Text, Text, Text, Text> { private Text word = new Text(); private Text str = new Text(); public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String[] t = key.toString().split(&quot;amp;quot;&quot;); word.set(t[0]);// str.set(t[1]); output.collect(word,str);//uid kind }//reduce }//Reduce0b Hadoop 案例 (2)
  • 16. public static class MapClass2 extends MapReduceBase implements Mapper<LongWritable, Text, Text, Text> { private Text word = new Text(); private Text str = new Text(); public void map(LongWritable Key, Text value, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String strLine = value.toString(); String[] strList = strLine.split(&quot;s+&quot;); word.set(strList[0]); str.set(strList[1]); output.collect(word,str); } } Hadoop 案例 (3)
  • 17. public static class Reducer2 extends MapReduceBase implements Reducer<Text, Text, Text, Text> { private Text word = new Text(); private Text str = new Text(); public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { while(values.hasNext()) { String t = values.next().toString(); // 省略数十行代码 } // 省略数十行代码 output.collect(new Text(mid + “” + sid + “”) + ...., ...) } Hadoop 案例 (4)
  • 18. B A D A A C B C B C D Group Co-group Function Aggregate Filter Filter Thinking in MapReduce(1)
  • 20. Magics of Hive: SELECT COUNT(DISTINCT mid) FROM log_table Hive 的魔力
  • 21. 为什么淘宝采用 Hadoop? webalizer awstat  般若 Atpanel 时代 日志最高达 250GB/ 天 最高达约 50 道作业 每天运行 20 小时以上 Hadoop 时代 当前日志 470GB/ 天 当前 366 道作业 平均 6~7 小时完成
  • 22. 还有谁在用 Hadoop? 雅虎北京全球软件研发中心 中国移动研究院 英特尔研究院 金山软件 百度 腾讯 新浪 搜狐 IBM Facebook Amazon Yahoo!
  • 23. Web Servers Log Collection Servers Filers Data Warehousing on a Cluster Oracle RAC Federated MySQL Web 站点的典型 Hadoop 架构
  • 24. 淘宝 Hadoop 与 Hive 的使用 Hadoop Rich Client MetaStore Server Mysql Scheduler Thrift Server Web JobClient CLI/GUI Client Program Web Server
  • 25. 标准输出 , 标准出错 Web 显示 (50030, 50060, 50070) NameNode,JobTracker, DataNode, TaskTracker 日志 本地重现 : Local Runner DistributedCache 中放入调试代码 调试
  • 26. 目的:查性能瓶颈,内存泄漏,线程死锁等 工具: jmap, jstat, hprof,jconsole, jprofiler mat,jstack 对 JobTracker 的 Profile 对各 slave 节点 TaskTracker 的 Profile 对各 slave 节点某 Child 进程的 Profile( 可能存在单点执行速度过慢 ) Profiling
  • 27. 目的:监控集群或单个节点 I/O, 内存及 CPU 工具: Ganglia 监控
  • 30.