oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is...

35
1 版权所有 © 2011Oracle /或其分支机构。保留所有权利。 Oracle 大数据连接器 HadoopOracle 数据库集成 罗海雄 资深技术顾问

Upload: vukhanh

Post on 27-May-2018

223 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

1 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle 大数据连接器

Hadoop与 Oracle 数据库集成

罗海雄 资深技术顾问

Page 2: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

以下内容旨在概述产品的总体发展方向。该内容仅供参考,不可

纳入任何合同。该信息不承诺提供任何资料、代码或功能,并且

不应该作为制定购买决策的依据。描述的有关 Oracle 产品的任

何特性或功能的开发、发行和时间规划均由 Oracle 自行决定。

Page 3: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

3 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

获取、组织、分析所有数据

Oracle

数据库云服务器

获取 组织 分析和可视化 流

Oracle

商务智能云服务器

Oracle

大数据机

Oracle

Big Data

Connectors

Endeca Information Discovery

Page 4: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

4 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

议题

• Oracle Hadoop装载器

• Oracle Hadoop分布式文件系统直接连接器

• Oracle Data Integrator Hadoop适配器

• Oracle R Hadoop连接器

• 总结

Page 5: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

5 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Hadoop装载器

概述

MapReduce 工作流的

最后阶段

分区表和未分区表 在线和离线加载

SHUFFLE

/SORT

SHUFFLE

/SORT

REDUCE

REDUCE

REDUCE

MAP

MAP

MAP

MAP

MAP

MAP

REDUCE

REDUCE

ORACLE HADOOP装载器

Page 6: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

6 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Hadoop装载器

SHUFFLE /SORT

SHUFFLE /SORT

REDUCE

REDUCE

REDUCE

MAP

MAP

MAP

MAP

MAP

MAP

REDUCE

REDUCE

3. 从Reducer节点连接到数据库,并行加载到数据库分区(JDBC 或 OCI方式)

3. 从Reducer节点连接到数据库,并行加载到数据库分区(JDBC 或 OCI方式)

1. 从数据库读取目标表元数据 1. 从数据库读取目标表元数据

2.执行分区、排序和数据转换

2.执行分区、排序和数据转换

在线模式

Page 7: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

7 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Hadoop装载器

SHUFFLE /SORT

SHUFFLE /SORT

REDUCE

REDUCE

REDUCE

MAP

MAP

MAP

MAP

MAP

MAP

REDUCE

REDUCE

1. 从数据库读取目标表元数据 1. 从数据库读取目标表元数据

2. 执行分区、排序和数据转换

2. 执行分区、排序和数据转换

3. 从Reducer节点写入 Oracle Data Pump 文件

3. 从Reducer节点写入 Oracle Data Pump 文件

5. 使用外部表机制并行导入数据库

5. 使用外部表机制并行导入数据库

数据

数据

数据

数据

数据

4. 将文件从 HDFS 复制到数据库可以访问这些文件的位置

4. 将文件从 HDFS 复制到数据库可以访问这些文件的位置

离线模式

4. 1 使用 ODCH 访问 HDFS 中的 datapump 文件(稍后介绍)

4. 1 使用 ODCH 访问 HDFS 中的 datapump 文件(稍后介绍)

Page 8: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

8 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Hadoop装载器

• 步骤1: 选中数据输入格式 使用内置的格式:Hive表输入-HivetoAvro 或者文本文件-DelimitedText

或者自己写Java类,实现接口:org.apache.hadoop.mapreduce.RecordReader以支持自定义格式

• 步骤2: 创建装载器映射文档 创建装载器映射文档, 说明目标表,列,以及列和输入数据的映射关系

• 步骤3: 指定表的元数据 指定JDBC连接,装载器自动从数据库中获取,适用于Loader直连接数据库的情况

或者通过 OraLoaderMetadata 工具将元数据提取成XML格式的文档,适用于Loader不直接连接数据库

• 步骤4: 运行装载器 Run: hadoop ${OLH_HOME}/jlib/oraloader.jar oracle.hadoop.loader.OraLoader -conf MyConf.xml

• 步骤5: 如果使用离线模式,则需要处理离线文件

实施步骤

Page 9: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

9 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Hadoop装载器

• 将数据库服务器处理压力分流到 Hadoop:

– 将输入数据转换为最终数据库格式

– 对数据进行预分区

– 在表分区内按主键对行进行排序

– 使用 OCI 在线加载模式时,进行高性能的直接路径加载

• 生成二进制 datapump 文件

• 跨Reducer的负载均衡

优点:与 SQOOP、OraOOP 相比较

Page 10: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

10 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

议题

• Oracle Hadoop装载器

• Oracle Hadoop分布式文件系统直接连接器

• Oracle Data Integrator Hadoop适配器

• Oracle R Hadoop连接器

• 总结

Page 11: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

11 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Hadoop分布式文件系统直接连接器 从 Oracle 数据库直接访问

对 HDFS 的 SQL 访问 外部表视图 数据查询或导入

DCHDCH DCHDCH

外部表

DCHDCH DCHDCH

DCHDCH DCHDCH

SQL 查询

Infini Band

HDFS

客户端

HDFS

Oracle 数据库

Page 12: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

12 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Hadoop分布式文件系统直接连接器

SHUFFLE /SORT

SHUFFLE /SORT

REDUCE

REDUCE

REDUCE

MAP

MAP

MAP

MAP

MAP

MAP

REDUCE

REDUCE

数据

数据

数据

数据

数据

任何 MAPREDUCE 作业 外部表

SQL 查询

ODCHODCH ODCHODCH

1. 创建外部表 1. 创建外部表

2. 发布 HDFS 数据文件路径 2. 发布 HDFS 数据文件路径

3. 通过外部表访问数据 3. 通过外部表访问数据

Page 13: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

13 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Hadoop分布式文件系统直接连接器

• 步骤1: 定义好外部表 CREATE TABLE SALES_HDFS_EXT_TAB ( .. )

ORGANIZATION EXTERNAL ( TYPE ORACLE_LOADER DEFAULT DIRECTORY "SALES_EXT_DIR"

ACCESS PARAMETERS (

RECORDS DELIMITED BY NEWLINE FIELDS TERMINATED BY ',‘

(PREPROCESSOR "HDFS_BIN_PATH:hdfs_stream“ )

LOCATION ('sales1','sales2','sales3')

);

hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB.

• 步骤2: 生成HDFS文件对应的位置文件 hadoop jar orahdfs.jar oracle.hadoop.hdfs.exttab.ExternalTable -conf config_file -publish

实施步骤

Page 14: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

14 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Hadoop分布式文件系统直接连接器

• 直接访问 HDFS 上的数据文件(无需 FUSE 插件)

– 创建指向 HDFS 上文件位置的外部表

– 使用 SQL 从数据库查询数据

– 需要时将数据加载到数据库

• 快速数据移动:并行、优化、自动负载平衡

• 数据文件可以是

– 带分隔符文本文件格式原始数据

– Oracle Loader for Hadoop 创建的 Data Pump 文件

优势

Page 15: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

15 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

从 Oracle 数据库访问 Hadoop 数据

Oracle Loader for Hadoop 用例特性

通过 JDBC 在线加载 最简单的未分区表用例

通过直接路径在线加载 分区表的快速在线加载

通过 datapump 文件离线加载 外部表的最快加载方法

数据库服务器上的加载较少

避开高峰期

Oracle Direct Connector for HDFS

从 Oracle 数据库对 HDFS 进行 SQL 访问 数据留在 HDFS 上

从数据库并行访问

与 Oracle Loader for Hadoop 联用 访问由 OLH 创建的文件或导入 Oracle 表

Page 16: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

16 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

议题

• Oracle Hadoop装载器

• Oracle Hadoop分布式文件系统直接连接器

• Oracle Data Integrator Hadoop适配器

• Oracle R Hadoop连接器

• 总结

Page 17: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

17 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Data Integrator 企业版 高性能、产能和低TCO

基于集的声明式设计

数据变更的捕获

E-LT 转换 与 E-T-L

可热插拔的架构

任何数据仓库

任何计划系统

OLTP 数据库源

应用程序源

传统数据源

可插入的知识模块

Page 18: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

18 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Data Integrator 企业版

下一代架构

“E-LT” “E-LT” 加载 提取

传统 ETL 架构

提取 加载 转换

• E-LT 提供了灵活的架构以优化性能

益处:

• 利用基于集的转换

• 无额外的网络传输节点

• 利用现有硬件

转换 转换

手动 脚本

手动 脚本

通过 E-LT 优化了数据加载

Page 19: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

19 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

可插入的知识模块架构

SAP/R3

Siebel

Log Miner

DB2 Journals

SQL Server Triggers

Oracle DBLink

DB2 Exp/Imp

JMS Queues Check MS Excel

Check Sybase Oracle

SQL*Loader

TPump/Multiload

Type II SCD

Oracle Merge

Siebel EIM Schema

Oracle Web 服务

DB2 Web Services

现成的知识模块示例

元数据的反向工程

日志记录 (CDC)

从源加载到临时存储

检查约 束条件 集成、转换 数据服务

ODI-EE 知识模块 能提供灵活性和可扩展性

Page 20: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

20 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

自动生成 MapReduce 代码 管理进程 加载到数据仓库

Oracle

Hadoop装载器

Oracle

Hadoop装载器

Oracle Data Integrator

Oracle Data Integrator

Oracle Data Integrator Hadoop适配器 提高大数据产能和效率

Page 21: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

21 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

SHUFFLE /SORT

SHUFFLE /SORT

REDUCE

REDUCE

REDUCE

MAP

MAP

MAP

MAP

MAP

MAP

REDUCE

REDUCE

1. 将本地文件或 HDFS 文件加载到 Hive 数据库

1. 将本地文件或 HDFS 文件加载到 Hive 数据库

数据

数据

数据

数据

数据

HDFS

ORACLE 数据库

ODCHODCH ODCHODCH

2. 在 Hive 中转换和验证数据

2. 在 Hive 中转换和验证数据

3. 将处理后的数据从 Hive 加载到 Oracle 中

3. 将处理后的数据从 Hive 加载到 Oracle 中

Oracle Data Integrator Hadoop适配器

Page 22: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

22 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Data Integrator Hadoop适配器

知识模块

1. 将本地文件或 HDFS 文件加载到 Hive 数据库

知识模块 -- IKM File to Hive

2. 在 Hive 中转换和验证数据

知识模块 -- IKM Hive Control Append

知识模块 -- IKM Hive Transform

知识模块 -- RKM Hive

3. 将处理后的数据从 Hive 加载到 Oracle 数据库中

知识模块 -- IKM File/Hive to Oracle (OLH)

Page 23: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

23 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Data Integrator Hadoop适配器

• 提高数据集成性能 – 在 Hadoop 集群中处理大部分任务,以利用 Hadoop 集群的资源

– 使用高性能的 Hive 知识模块

– 使用高性能的 OLH 知识模块

• 提高开发和数据集成效率 – 使用统一的 ODI 编程接口

– 使用与 SQL 类似的 HiveQL 语言。无需编写 Map/Reduce 程序。

– 在 ODI 内进行 Hadoop 作业调度

优势

Page 24: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

24 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

议题

• Oracle Hadoop装载器

• Oracle Hadoop分布式文件系统直接连接器

• Oracle Data Integrator Hadoop适配器

• Oracle R Hadoop连接器

• 总结

Page 25: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

25 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle R Hadoop连接器 实现在原生R 中访问 Hadoop

ORE ORE

客户端主机

R 引擎

Hadoop

集群 软件

R 引擎

MapReduce

节点

HDFS

Oracle

大数据机

Oracle

数据库云服务器

R 引擎

ORE ORE

ORHC ORHC ORHC ORHC

原生的R MapReduce

原生的R HDFS 访问

Page 26: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

26 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

若不用 ORHC,则需 Java 技能 — Mapper和Reducer import java.io.IOException;

import org.apache.hadoop.io.IntWritable;

import org.apache.hadoop.io.LongWritable;

import org.apache.hadoop.io.Text;

import org.apache.hadoop.mapred.MapReduceBase;

import org.apache.hadoop.mapred.Mapper;

import org.apache.hadoop.mapred.OutputCollector;

import org.apache.hadoop.mapred.Reporter;

public class WordMapper extends MapReduceBase

implements Mapper<LongWritable, Text, Text,

IntWritable> {

public void map(LongWritable key, Text value,

OutputCollector<Text, IntWritable> output, Reporter

reporter)

throws IOException {

String s = value.toString();

for (String word :s.split("\\W+")) {

if (word.length() > 0) {

output.collect(new Text(word), new

IntWritable(1));

}

}

}

}

import java.io.IOException;

import java.util.Iterator;

import org.apache.hadoop.io.IntWritable;

import org.apache.hadoop.io.Text;

import org.apache.hadoop.mapred.OutputCollector;

import org.apache.hadoop.mapred.MapReduceBase;

import org.apache.hadoop.mapred.Reducer;

import org.apache.hadoop.mapred.Reporter;

public class SumReducer extends MapReduceBase implements

Reducer<Text, IntWritable, Text, IntWritable> {

public void reduce(Text key, Iterator<IntWritable>

values,

OutputCollector<Text, IntWritable> output, Reporter

reporter)

throws IOException {

int wordCount = 0;

while (values.hasNext()) {

IntWritable value = values.next();

wordCount += value.get();

}

output.collect(key, new IntWritable(wordCount));

}

}

Page 27: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

27 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

在R中直接使用Map/Reduce • dfs <- hdfs.attach("ontime_DB")

• res <- hadoop.run(

dfs,

mapper = function(key, value) {

if (key == 'SFO' & !is.na(x$ARRDELAY)) {

keyval(key, value)

}

else {

NULL

}

},

reducer = function(key, values) {

for (x in values) {

sumAD <- sumAD + x$ARRDELAY

count <- count + 1

}

res <- sumAD / count

keyval(key, res)

})

> hdfs.get(res)

key val1

1 SFO 17.44828

Page 28: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

28 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle R Hadoop连接器

架构 客户端主机(例如笔记本电脑)

R 引擎

orhc

Hadoop

集群软件 Java VM

服务器(例如大数据机)

R 引擎

orhc-drv 包 Java VM

DBMS 机(例如数据库云服务器)

R 引擎

ORE

Oracle 数据库

ORE 软件包

Hadoop 集群

任务节点

任务节点

JobTracker

MapReduce

节点

HDFS 节点

数据节点

数据节点

名称节点

ORE 软件包

ORE 客户端软件包 orhc

Page 29: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

29 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle R Hadoop连接器 优势

• 支持透明访问 Hadoop 集群:MapReduce 和 HDFS 文件

• R 用户无需学习新语言或了解界面即可使用 Hadoop

• 可以利用开源的 R 软件包处理 HDFS文件

• 工作从实验室过渡到 Hadoop 集群上的生产部署无需了解 Hadoop 内幕、Hadoop CLI、或 IT 基础架构

• Hadoop 集群管理员无需学习 R 即可在生产中进行 R MapReduce 作业调度

Page 30: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

30 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

议题

• Oracle Hadoop装载器

• Oracle Hadoop分布式文件系统直接连接器

• Oracle Data Integrator Hadoop适配器

• Oracle R Hadoop连接器

• 总结

Page 31: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

31 版权所有 © 2011,Oracle 和/或其分支机构。保留所有权利。

Oracle Big Data Connectors

• Oracle Loader for Hadoop – 实现 Hadoop 数据到 Oracle 数据库的高性能加载

• Oracle Direct Connector for HDFS – 支持使用 SQL 对 Hadoop 数据进行高性能、高效访问

• Oracle Data Integrator – 在本地解释 Hive 元数据并生成优化的 HiveQL 代码

• Oracle R Connector for Hadoop – 支持从 R 对 Hadoop 数据进行交互式访问

总结

Page 33: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner

问答

Page 34: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner
Page 35: Oracle 自行决定。 ('sales1','sales2','sales3') ); hdfs_stream is a map/reduce program to extract HDFS data file as data stream for Oracle DB. ... Siebel Log Miner