sqoop架构_SQOOP架构的深入介绍
sqoop架构
by Jayvardhan Reddy
通过杰伊瓦尔丹·雷迪(Jayvardhan Reddy)
SQOOP架构的深入介绍 (An in-depth introduction to SQOOP architecture)
Apache Sqoop is a data ingestion tool designed for efficiently transferring bulk data between Apache Hadoop and structured data-stores such as relational databases, and vice-versa.
Apache Sqoop是一种数据提取工具,旨在在Apache Hadoop和结构化数据存储(例如关系数据库)之间有效地传输批量数据,反之亦然。
As part of this blog, I will be explaining how the architecture works on executing a Sqoop command. I’ll cover details such as the jar generation via Codegen, execution of MapReduce job, and the various stages involved in running a Sqoop import/export command.
作为该博客的一部分,我将解释该架构如何执行Sqoop命令。 我将介绍诸如通过Codegen生成jar,执行MapReduce作业以及运行Sqoop导入/导出命令所涉及的各个阶段等细节。
码元 (Codegen)
Understanding Codegen is essential, as internally this converts our Sqoop job into a jar which consists of several Java classes such as POJO, ORM, and a class that implements DBWritable, extending SqoopRecord to read and write the data from relational databases to Hadoop & vice-versa.
理解Codegen是必不可少的,因为在内部,这会将我们的Sqoop作业转换为一个jar,该jar由几个Java类(例如POJO,ORM)和一个实现DBWritable的类组成,将SqoopRecord扩展为从关系数据库到Hadoop读写数据,反之亦然。反之亦然。
You can create a Codegen explicitly as shown below to check the classes present as part of the jar.
您可以如下所示显式创建Codegen,以检查作为jar一部分存在的类。
sqoop codegen \ -- connect jdbc:mysql://ms.jayReddy.com:3306/retail_db \ -- username retail_user \ -- password ******* \ -- table products
The output jar will be written in your local file system. You will get a Jar file, Java file and java files which are compiled into .class files:
输出jar将被写入您的本地文件系统中。 您将获得一个Jar文件,Java文件和编译为.class文件的Java文件:
Let us see a snippet of the code that will be generated.
让我们看一看将要生成的代码片段。
ORM class for table ‘products’ // Object-relational modal generated for mapping:
表“产品”的ORM类//为映射生成的对象关系模态:
Setter & Getter methods to get values:
用Setter和Getter方法获取值:
Internally it uses JDBC prepared statements to write to Hadoop and ResultSet to read data from Hadoop.
在内部,它使用JDBC准备的语句写入Hadoop,并使用ResultSet从Hadoop读取数据。
Sqoop导入 (Sqoop Import)
It is used to import data from traditional relational databases into Hadoop.
它用于将数据从传统的关系数据库导入Hadoop。
Let’s see a sample snippet for the same.
让我们看一下相同的示例代码。
sqoop import \ -- connect jdbc:mysql://ms.jayReddy.com:3306/retail_db \ -- username retail_user \ -- password ******* \ -- table products \ -- warehouse-dir /user/jvanchir/sqoop_prac/import_table_dir \ -- delete-target-dir
The following steps take place internally during the execution of sqoop.
在执行sqoop时,以下步骤在内部进行。
Step 1: Read data from MySQL in streaming fashion. It does various operations before writing the data into HDFS.
步骤1 :以流方式从MySQL读取数据。 在将数据写入HDFS之前,它会执行各种操作。
As part of this process, it will first generate code (typical Map reduce code) which is nothing but Java code. Using this Java code it will try to import.
作为此过程的一部分,它将首先生成仅Java代码的代码(典型的Map reduce代码)。 使用此Java代码,它将尝试导入。
- Generate the code. (Hadoop MR)生成代码。 (Hadoop MR)
- Compile the code and generate the Jar file.编译代码并生成Jar文件。
- Submit the Jar file and perform the import operations提交Jar文件并执行导入操作
During the import, it has to make certain decisions as to how to divide the data into multiple threads so that Sqoop import can be scaled.
在导入期间,它必须对如何将数据划分为多个线程做出某些决策,以便可以扩展Sqoop导入。
Step 2: Understand the structure of the data and perform CodeGen
步骤2 :了解数据的结构并执行CodeGen
Using the above SQL statement, it will fetch one record along with the column names. Using this information, it will extract the metadata information of the columns, datatype etc.
使用上面SQL语句,它将获取一条记录以及列名。 使用此信息,它将提取列的元数据信息,数据类型等。
Step 3: Create the java file, compile it and generate a jar file
步骤3 :创建Java文件,对其进行编译并生成一个jar文件
As part of code generation, it needs to understand the structure of the data and it has to apply that object on the incoming data internally to make sure the data is correctly copied onto the target database. Each unique table has one Java file talking about the structure of data.
作为代码生成的一部分,它需要了解数据的结构,并且必须在内部将该对象应用于传入数据,以确保将数据正确复制到目标数据库中。 每个唯一表都有一个讨论数据结构的Java文件。
This jar file will be injected into Sqoop binaries to apply the structure to incoming data.
该jar文件将被注入Sqoop二进制文件中,以将结构应用于传入数据。
Step 4: Delete the target directory if it already exists.
步骤4 :删除目标目录(如果已存在)。
Step 5: Import the data
步骤5 :导入数据
Here, it connects to a resource manager, gets the resource, and starts the application master.
在这里,它连接到资源管理器,获取资源,然后启动应用程序主机。
To perform equal distribution of data among the map tasks, it internally executes a boundary query based on the primary key by default to find the minimum and maximum count of records in the table. Based on the max count, it will divide by the number of mappers and split it amongst each mapper.
为了在地图任务之间执行均等的数据分配,默认情况下,它会在内部基于主键执行边界查询,以查找表中记录的最小和最大计数。 根据最大计数,它将除以映射器的数量并将其分配给每个映射器。
It uses 4 mappers by default:
默认情况下,它使用4个映射器:
It executes these jobs on different executors as shown below:
它在不同的执行器上执行这些作业,如下所示:
The default number of mappers can be changed by setting the following parameter:
可以通过设置以下参数来更改默认的映射器数:
So in our case, it uses 4 threads. Each thread processes mutually exclusive subsets, that is each thread processes different data from the others.
因此,在我们的例子中,它使用4个线程。 每个线程处理互斥的子集,即每个线程处理彼此不同的数据。
To see the different values, check out the below:
要查看不同的值,请查看以下内容:
Operations that are being performed under each executor nodes:
在每个执行程序节点下正在执行的操作:
In case you perform a Sqooop hive import, one extra step as part of the execution takes place.
如果您执行Sqooop配置单元导入,则执行过程会多执行一个步骤。
Step 6: Copy data to hive table
步骤6 :将数据复制到配置单元表
Sqoop导出 (Sqoop Export)
This is used to export data from Hadoop into traditional relational databases.
这用于将数据从Hadoop导出到传统的关系数据库中。
Let’s see a sample snippet for the same:
让我们看一下相同的示例代码:
sqoop export \ -- connect jdbc:mysql://ms.jayReddy.com:3306/retail_export \ -- username retail_user \ -- password ******* \ -- table product_sqoop_exp \ -- export-dir /user/jvanchir/sqoop_prac/import_table_dir/products
On executing the above command, the execution steps (1–4) similar to Sqoop import take place, but the source data is read from the file system (which is nothing but HDFS). Here it will use boundaries upon block size to divide the data and it is internally taken care by Sqoop.
在执行上述命令时,将执行类似于Sqoop导入的执行步骤(1-4),但是从文件系统读取源数据(除了HDFS外什么也没有)。 在这里,它将使用块大小上的边界来划分数据,并且Sqoop会在内部对其进行处理。
The processing splits are done as shown below:
处理拆分如下所示:
After connecting to the respective database to which the records are to be exported, it will issue a JDBC insert command to read data from HDFS and store it into the database as shown below.
连接到要将记录导出到的相应数据库后,它将发出JDBC插入命令以从HDFS读取数据并将其存储到数据库中,如下所示。
Now that we have seen how Sqoop works internally, you can determine the flow of execution from jar generation to execution of a MapReduce task on the submission of a Sqoop job.
现在我们已经了解了Sqoop的内部工作原理,您可以确定从jar生成到提交Sqoop作业时执行MapReduce任务的执行流程。
Note: The commands that were executed related to this post are added as part of my GIT account.
注意:与该帖子相关的已执行命令被添加为我的GIT帐户的一部分。
Similarly, you can also read more here:
同样,您也可以在此处内容:
Hive Architecture in Depth with code.
具有代码 深度的Hive架构 。
HDFS Architecture in Depth with code.
具有代码 深度的HDFS体系结构 。
If you would like too, you can connect with me on LinkedIn - Jayvardhan Reddy.
如果您愿意,也可以通过LinkedIn- Jayvardhan Reddy与我联系 。
If you enjoyed reading this article, you can click the clap and let others know about it. If you would like me to add anything else, please feel free to leave a response ?
如果您喜欢阅读本文,则可以单击拍手并告知其他人。 如果您希望我添加其他任何内容,请随时回复。
翻译自: https://www.freecodecamp.org/news/an-in-depth-introduction-to-sqoop-architecture-ad4ae0532583/
sqoop架构
相关文章:

JS实现录音,播放完整代码带示例图
效果图: 实现代码: <!DOCTYPE html> <html><head><script src"recorder.js" type"text/javascript" charset"utf-8"></script><meta name"viewport" content"widthdevi…

r.json()
requests模块中,r.json()为Requests中内置的JSON解码器 其中只有response返回为json格式时,用r.json()打印出响应的内容, 如果response返回不为json格式,使用r.json()会报错 报错内容:ValueError: Expecting property …

冒泡排序语法树
转载于:https://www.cnblogs.com/alfredzhu/p/4939268.html

valve 的设计_向Valve Portal开发人员学习游戏设计原则
valve 的设计In this talk, Valve programers who created the game Portal discuss problems they faced in development and how they solved them. Leaning about how they solved Portal problems can give you insight into how to design better games.在本次演讲中&…

Android之控件使用
Android系统为我们提供了大量的控件,例如:开关控件、单选按钮、多选按钮、单选菜单等等,那么这些控件如何使用呢?本篇我将带领大家一道学习一下如何使用这些控件。所谓无图无真相,先让大家看一下效果图: 下…

《对软件工程课程的期望》
要学习到的能力的预期:要学会个人,结对,团队的代码编辑流程,学会和别人进行交流。 对项目课程的期望:希望不是枯燥的代码详解。 对项目的愿景规划:希望团队里的每个人都能学到有用的知识。转载于:https://w…

HTML发送语音,上传音频PHP接收
实现需求:网页录制音频上传给后端接收,接收后PHP把文件的名字存到数据库的表里面,这里我的后端用的是PHP,并且把代码贴出来了。 前端实现代码: <!DOCTYPE HTML> <html><head><meta http-equiv&q…

html:漂亮的原生表格_HTML表格:关于它们的所有知识
html:漂亮的原生表格by Alexander Gilmanov亚历山大吉尔马诺夫(Alexander Gilmanov) HTML表格:关于它们的所有知识 (HTML Tables: All there is to know about them) Judging by the fact that we created wpDataTables, it’s no secret that we like tables. So …

[BZOJ] 1606: [Usaco2008 Dec]Hay For Sale 购买干草
1606: [Usaco2008 Dec]Hay For Sale 购买干草 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1335 Solved: 989[Submit][Status][Discuss]Description 约翰遭受了重大的损失:蟑螂吃掉了他所有的干草,留下一群饥饿的牛.他乘着容量为C(1≤C≤…

PHP TP5框架 安装运行 Warning: require(E:\phpstudy_pro\WWW\TP5\tp5\public/../thinkphp/base.php): failed to
创建一个新的项目:进入项目的根目录执行 git 命令: 先执行 git clone -b 5.1 https://git.coding.net/liu21st/thinkphp5.git tp5 进入 tp5目录 cd tp5再执行 git clone -b 5.1 https://git.coding.net/liu21st/framework.git thinkphp 执行更新框…

python之模块base64
# -*- coding: cp936 -*- #python 27 #xiaodeng>>> help(base64) #用来作base64编码解码 FUNCTIONS #函数(功能) •b16decode(s, casefoldFalse)Decode a Base16 encoded string. #解码 decode_stringbase64…

github pages_使用GitHub Pages和Lighthouse增强您的开发人员产品组合
github pagesFor someone who is trying to break into software development, it doesn’t matter where you look — LinkedIn, career advice boards, youtube tutorials — the advice is always the same: you need a portfolio. freeCodeCamp knows this advise, and the…

Angular 4+ HttpClient
个人博客迁移至 http://www.sulishibaobei.com 处; 这篇,算是上一篇Angular 4 Http的后续; Angular 4.3.0-rc.0 版本已经发布?。在这个版本中,我们等到了一个令人兴奋的新功能 - HTTPClient API 的改进版本; HttpCli…

PHP TP5入门 二:写接口,添加控制器并访问
默认访问地址:http://localhost/TP5/tp5/public/index.php/index/hello_world 实现代码: <?php namespace app\index\controller;class HelloWorld {public function index(){return 22hello,world!;} } 添加一个控制器如…

Possion 分布
泊松分布的概率函数为: \[P(Xk)\frac{\lambda^k}{k!}e^{-\lambda},k0,1,2,\cdots\] 如果 $X_i \sim P(\lambda_i)$,并且 互相独立,那么: \[Y\left( \sum\limits_{i1}^n{X_i} \right) \sim P \left( \sum\limits_{i1}^n{\lambda_i} \right)\] 从上面公式…

如何使您的Kotlin Android动画可访问
When researching examples for a first ever Android contribution, few examples existed for animations written in Kotlin. There were also few code examples of accessibility considerations within native animations.在研究有史以来第一个Android贡献的示例时&#…

指针空间的申请与释放
一、malloc()和free()的基本概念以及基本用法: 1、函数原型及说明: void *malloc(long NumBytes):该函数分配了NumBytes个字节,并返回了指向这块内存的指针。如果分配失败,则返回一个空指针(NULL࿰…

UIGraphicsBeginImageContext - 位图上下文
UIGraphicsBeginImageContext 首先,先来认识一个UIGraphicsBeginImageContext,它会创建一个基于位图的上下文(context)(默认创建一个透明的位图上下文),并将其设置为当前上下文。 位图图形上下文UIKit是不会负责创建的,…

小程序双击事件
代码: <button data-time"{{lastTapTime}}" data-title"标题" bindtap"doubleClick">双击</button> js data: {lastTapTime:0,}, doubleClick: function (e) {var curTime e.timeStampvar lastTime e.currentTarget…

快速了解Kubernetes微服务中的通信
by Adam Henson亚当汉森(Adam Henson) 快速了解Kubernetes微服务中的通信 (A quick look at communication in Kubernetes microservices) “服务”概念和一个Node.js示例 (The “service” concept and a Node.js example) Based on complexity, a layer of microservices ca…

连接 linux服务器
操作步骤: xshell 下载 https://xshell.en.softonic.com/ 点击下载后,会有邮箱验证,点击验证通过就会自动下载,然后安装就行。 打开工具,点击新建会话 然后 浏览文件后直接点击确认,出来这样就登录成功了…

【bzoj3924】[Zjoi2015]幻想乡战略游戏 动态点分治
题目描述 傲娇少女幽香正在玩一个非常有趣的战略类游戏,本来这个游戏的地图其实还不算太大,幽香还能管得过来,但是不知道为什么现在的网游厂商把游戏的地图越做越大,以至于幽香一眼根本看不过来,更别说和别人打仗了。 …

面试题05-UI控件
怎么解决缓存池满的问题(cell)ios中不存在缓存池满的情况,因为通常我们ios中开发,对象都是在需要的时候才会创建,有种常用的说话叫做懒加载,还有在UITableView中一般只会创建刚开始出现在屏幕中的cell,之后都是从缓存池…

全球链界科技发展大会_如何成为科技界的团队合作者
全球链界科技发展大会by Ofer Vugman由Ofer Vugman 如何成为科技界的团队合作者 (How to be a team player in the tech world) 这些技巧将增进您的关系并提高团队的工作效率 (These tips will boost your relationships and your team’s efficiency at work) When I landed …

linux驱动之i2c子系统mpu6050设备驱动
以下是mpu6050简单的驱动实现,mpu6050是I2C接口的6轴传感器,可以作为字符设备注册到内核,本代码运行环境是3.4.2内核,4.3.2版本的编译链,12.04版本的Ubuntu,硬件环境是jz2440开发板; 按照之前分…

小程序使用富文本完整代码及示例图
先看示例图: 富文本html代码: 效果图: 实现步骤: 1.下载 wxParse代码放到你的小程序项目目录里面 https://github.com/icindy/wxParse 基本使用方法 Copy文件夹wxParse - wxParse/-wxParse.js(必须存在)-html2json.js(必须存在…

C# 百分比的获取
这里介绍 C# 百分比转换有2种方式 例: double a50; double b100; a/b.ToString("0.00%"); 或 a/b.ToString("P3"); p后的数字表示能显示小数点后几位的精度数 实际如: 方法一:a/b.ToString("0.00%"); 方法二&a…

css 网格布局_我从CSS网格布局中学到的东西
css 网格布局by Jennifer Wjertzoch珍妮弗维佐奇 我从CSS网格布局中学到的东西 (Things I’ve learned about CSS grid layout) With CSS Grid you can create complex web designs. It is very intuitive and very well supported by the major browsers. In this article I …
GoF23种设计模式之行为型模式之解释器模式
一、概述 给定一种语言和其文法的一种表示,再定义一个解释器,该解释器使用表示来解释语言中的句子。 二、适用性 当需要解释一种语言,并且可以将该语言中的句子表示为一个抽象语法树的时候。 1.该文法简单对于复杂的文法&…

U盘安装Ubuntu14.4时遇到分区问题记录
1、在安装Ubuntu14.4时,遇到如果先分出 / 跟挂载的主分区时,后面只能再分一个swap,或者挂载一个/home,或者一个/ boot 时不能继续分区,当然想安装也是不能不能成功的。 解决办法:在这里先不要创建 / 的主挂…