大数据技术之Hudi

第1章 Hudi概述

1.1 Hudi简介

Apache Hudi(Hadoop Upserts Delete and Incremental)是下一代流数据湖平台。Apache Hudi将核心仓库和数据库功能直接引入数据湖。Hudi提供了表、事务、高效的upserts/delete、高级索引、流摄取服务、数据集群/压缩优化和并发,同时保持数据的开源文件格式。

Apache Hudi不仅非常适合于流工作负载,而且还允许创建高效的增量批处理管道。

Apache Hudi可以轻松地在任何云存储平台上使用。Hudi的高级性能优化,使分析工作负载更快的任何流行的查询引擎,包括Apache Spark、Flink、Presto、Trino、Hive等。

1.2 发展历史

2015 年:发表了增量处理的核心思想/原则(O'reilly 文章)。

2016 年:由 Uber 创建并为所有数据库/关键业务提供支持。

2017 年:由 Uber 开源,并支撑 100PB 数据湖。

2018 年:吸引大量使用者,并因云计算普及。

2019 年:成为 ASF 孵化项目,并增加更多平台组件。

2020 年:毕业成为 Apache 顶级项目,社区、下载量、采用率增长超过 10 倍。

2021 年:支持 Uber 500PB 数据湖,SQL DML、Flink 集成、索引、元服务器、缓存。

1.3 Hudi特性

  • 可插拔索引机制支持快速Upsert/Delete。
  • 支持增量拉取表变更以进行处理。
  • 支持事务提交及回滚,并发控制。
  • 支持Spark、Presto、Trino、Hive、Flink等引擎的SQL读写。
  • 自动管理小文件,数据聚簇,压缩,清理。
  • 流式摄入,内置CDC源和工具。
  • 内置可扩展存储访问的元数据跟踪。
  • 向后兼容的方式实现表结构变更的支持。

1.4 使用场景

1)近实时写入

  • 减少碎片化工具的使用。
  • CDC 增量导入 RDBMS 数据。
  • 限制小文件的大小和数量。

2)近实时分析

  • 相对于秒级存储(Druid, OpenTSDB),节省资源。
  • 提供分钟级别时效性,支撑更高效的查询。
  • Hudi作为lib,非常轻量。

3)增量 pipeline

  • 区分arrivetime和event time处理延迟数据。
  • 更短的调度interval减少端到端延迟(小时 -> 分钟) => Incremental Processing。

4)增量导出

替代部分Kafka的场景,数据导出到在线服务存储 e.g. ES。

第2章 编译安装

2.1 编译环境准备

本次的相关组件版本如下:

Hadoop

3.1.3

Hive

3.1.2

Flink

1.13.6,scala-2.12

Spark

3.2.2,scala-2.12

1)安装Maven

(1)上传apache-maven-3.6.1-bin.tar.gz到/opt/soft目录,并解压更名

[hadoop@hadoop1 hudi]$ tar -zxvf apache-maven-3.6.1-bin.tar.gz -C /opt/mod/
mv apache-maven-3.6.1 maven-3.6.1

(2)添加环境变量到/etc/profile.d/my_env.sh中

[hadoop@hadoop1 mod]$ sudo vi /etc/profile.d/my_env.sh
#MAVEN_HOME
export MAVEN_HOME=/opt/mod/maven-3.6.1
export PATH=$PATH:$MAVEN_HOME/bin

(3)测试安装结果

[hadoop@hadoop1 mod]$ source /etc/profile.d/my_env.sh 
[hadoop@hadoop1 mod]$ mvn -v

2)修改为阿里镜像

(1)修改setting.xml,指定为阿里仓库地址

[hadoop@hadoop1 mod]$ vi /opt/mod/maven-3.6.1/conf/settings.xml<!-- 添加阿里云镜像-->
<mirror><id>nexus-aliyun</id><mirrorOf>central</mirrorOf><name>Nexus aliyun</name><url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

2.2 编译Hudi

2.2.1 上传源码包

将hudi-0.12.0.src.tgz上传到/opt/soft,并解压

[hadoop@hadoop1 mod]$ tar -zxvf /opt/soft/hudi/hudi-0.12.0.src.tgz -C /opt/soft
2.2.2 修改pom文件
[hadoop@hadoop1 mod]$ vi /opt/soft/hudi-0.12.0/pom.xml

1)新增repository加速依赖下载

<repository><id>nexus-aliyun</id><name>nexus-aliyun</name><url>http://maven.aliyun.com/nexus/content/groups/public/</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots>
</repository>

2)修改依赖的组件版本

<hadoop.version>3.1.3</hadoop.version>
<hive.version>3.1.2</hive.version>
2.2.3 修改源码兼容hadoop3

Hudi默认依赖的hadoop2,要兼容hadoop3,除了修改版本,还需要修改如下代码:

[hadoop@hadoop1 mod]$ vi /opt/soft/hudi-0.12.0/hudi-common/src/main/java/org/apache/hudi/common/table/log/block/HoodieParquetDataBlock.java

修改第110行,原先只有一个参数,添加第二个参数null:

2.2.4 手动安装Kafka依赖

有几个kafka的依赖需要手动安装,否则编译报错如下:

1)下载jar包

通过网址下载:http://packages.confluent.io/archive/5.3/confluent-5.3.4-2.12.zip

解压后找到以下jar包,上传服务器hadoop1

  • common-config-5.3.4.jar

  • common-utils-5.3.4.jar

  • kafka-avro-serializer-5.3.4.jar

  • kafka-schema-registry-client-5.3.4.jar

2)install到maven本地仓库

[hadoop@hadoop1 hudi]$ pwd
/opt/soft/hudi[hadoop@hadoop1 hudi]$ mvn install:install-file -DgroupId=io.confluent -DartifactId=common-config -Dversion=5.3.4 -Dpackaging=jar -Dfile=./common-config-5.3.4.jar[hadoop@hadoop1 hudi]$ mvn install:install-file -DgroupId=io.confluent -DartifactId=common-utils -Dversion=5.3.4 -Dpackaging=jar -Dfile=./common-utils-5.3.4.jar[hadoop@hadoop1 hudi]$ mvn install:install-file -DgroupId=io.confluent -DartifactId=kafka-avro-serializer -Dversion=5.3.4 -Dpackaging=jar -Dfile=./kafka-avro-serializer-5.3.4.jar[hadoop@hadoop1 hudi]$ mvn install:install-file -DgroupId=io.confluent -DartifactId=kafka-schema-registry-client -Dversion=5.3.4 -Dpackaging=jar -Dfile=./kafka-schema-registry-client-5.3.4.jar

 2.2.5 解决spark模块依赖冲突

修改了Hive版本为3.1.2,其携带的jetty是0.9.3,hudi本身用的0.9.4,存在依赖冲突。

1)修改hudi-spark-bundle的pom文件,排除低版本jetty,添加hudi指定版本的jetty:

vi /opt/soft/hudi-0.12.0/packaging/hudi-spark-bundle/pom.xml

在382行的位置,修改如下:

<!-- Hive --><dependency><groupId>${hive.groupid}</groupId><artifactId>hive-service</artifactId><version>${hive.version}</version><scope>${spark.bundle.hive.scope}</scope><exclusions><exclusion><artifactId>guava</artifactId><groupId>com.google.guava</groupId></exclusion><exclusion><groupId>org.eclipse.jetty</groupId><artifactId>*</artifactId></exclusion><exclusion><groupId>org.pentaho</groupId><artifactId>*</artifactId></exclusion></exclusions></dependency><dependency><groupId>${hive.groupid}</groupId><artifactId>hive-service-rpc</artifactId><version>${hive.version}</version><scope>${spark.bundle.hive.scope}</scope></dependency><dependency><groupId>${hive.groupid}</groupId><artifactId>hive-jdbc</artifactId><version>${hive.version}</version><scope>${spark.bundle.hive.scope}</scope><exclusions><exclusion><groupId>javax.servlet</groupId><artifactId>*</artifactId></exclusion><exclusion><groupId>javax.servlet.jsp</groupId><artifactId>*</artifactId></exclusion><exclusion><groupId>org.eclipse.jetty</groupId><artifactId>*</artifactId></exclusion></exclusions></dependency><dependency><groupId>${hive.groupid}</groupId><artifactId>hive-metastore</artifactId><version>${hive.version}</version><scope>${spark.bundle.hive.scope}</scope><exclusions><exclusion><groupId>javax.servlet</groupId><artifactId>*</artifactId></exclusion><exclusion><groupId>org.datanucleus</groupId><artifactId>datanucleus-core</artifactId></exclusion><exclusion><groupId>javax.servlet.jsp</groupId><artifactId>*</artifactId></exclusion><exclusion><artifactId>guava</artifactId><groupId>com.google.guava</groupId></exclusion></exclusions></dependency><dependency><groupId>${hive.groupid}</groupId><artifactId>hive-common</artifactId><version>${hive.version}</version><scope>${spark.bundle.hive.scope}</scope><exclusions><exclusion><groupId>org.eclipse.jetty.orbit</groupId><artifactId>javax.servlet</artifactId></exclusion><exclusion><groupId>org.eclipse.jetty</groupId><artifactId>*</artifactId></exclusion></exclusions>
</dependency><!-- 增加hudi配置版本的jetty --><dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-server</artifactId><version>${jetty.version}</version></dependency><dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-util</artifactId><version>${jetty.version}</version></dependency><dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-webapp</artifactId><version>${jetty.version}</version></dependency><dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-http</artifactId><version>${jetty.version}</version></dependency>

否则在使用spark向hudi表插入数据时,会报错如下:

java.lang.NoSuchMethodError: org.apache.hudi.org.apache.jetty.server.session.SessionHandler.setHttpOnly(Z)V

2)修改hudi-utilities-bundle的pom文件,排除低版本jetty,添加hudi指定版本的jetty:

[hadoop@hadoop1 hudi]$ vi /opt/soft/hudi-0.12.0/packaging/hudi-utilities-bundle/pom.xml在405行的位置,修改如下 :
<!-- Hoodie --><dependency><groupId>org.apache.hudi</groupId><artifactId>hudi-common</artifactId><version>${project.version}</version><exclusions><exclusion><groupId>org.eclipse.jetty</groupId><artifactId>*</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.apache.hudi</groupId><artifactId>hudi-client-common</artifactId><version>${project.version}</version><exclusions><exclusion><groupId>org.eclipse.jetty</groupId><artifactId>*</artifactId></exclusion></exclusions></dependency><!-- Hive --><dependency><groupId>${hive.groupid}</groupId><artifactId>hive-service</artifactId><version>${hive.version}</version><scope>${utilities.bundle.hive.scope}</scope><exclusions><exclusion><artifactId>servlet-api</artifactId><groupId>javax.servlet</groupId></exclusion><exclusion><artifactId>guava</artifactId><groupId>com.google.guava</groupId></exclusion><exclusion><groupId>org.eclipse.jetty</groupId><artifactId>*</artifactId></exclusion><exclusion><groupId>org.pentaho</groupId><artifactId>*</artifactId></exclusion></exclusions></dependency><dependency><groupId>${hive.groupid}</groupId><artifactId>hive-service-rpc</artifactId><version>${hive.version}</version><scope>${utilities.bundle.hive.scope}</scope></dependency><dependency><groupId>${hive.groupid}</groupId><artifactId>hive-jdbc</artifactId><version>${hive.version}</version><scope>${utilities.bundle.hive.scope}</scope><exclusions><exclusion><groupId>javax.servlet</groupId><artifactId>*</artifactId></exclusion><exclusion><groupId>javax.servlet.jsp</groupId><artifactId>*</artifactId></exclusion><exclusion><groupId>org.eclipse.jetty</groupId><artifactId>*</artifactId></exclusion></exclusions></dependency><dependency><groupId>${hive.groupid}</groupId><artifactId>hive-metastore</artifactId><version>${hive.version}</version><scope>${utilities.bundle.hive.scope}</scope><exclusions><exclusion><groupId>javax.servlet</groupId><artifactId>*</artifactId></exclusion><exclusion><groupId>org.datanucleus</groupId><artifactId>datanucleus-core</artifactId></exclusion><exclusion><groupId>javax.servlet.jsp</groupId><artifactId>*</artifactId></exclusion><exclusion><artifactId>guava</artifactId><groupId>com.google.guava</groupId></exclusion></exclusions></dependency><dependency><groupId>${hive.groupid}</groupId><artifactId>hive-common</artifactId><version>${hive.version}</version><scope>${utilities.bundle.hive.scope}</scope><exclusions><exclusion><groupId>org.eclipse.jetty.orbit</groupId><artifactId>javax.servlet</artifactId></exclusion><exclusion><groupId>org.eclipse.jetty</groupId><artifactId>*</artifactId></exclusion></exclusions>
</dependency><!-- 增加hudi配置版本的jetty --><dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-server</artifactId><version>${jetty.version}</version></dependency><dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-util</artifactId><version>${jetty.version}</version></dependency><dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-webapp</artifactId><version>${jetty.version}</version></dependency><dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-http</artifactId><version>${jetty.version}</version></dependency>

否则在使用DeltaStreamer工具向hudi表插入数据时,也会报Jetty的错误。

2.2.6 执行编译命令
mvn clean package -DskipTests -Dspark3.2 -Dflink1.13 -Dscala-2.12 -Dhadoop.version=3.1.3 -Pflink-bundle-shade-hive3

 2.2.7 编译成功

编译成功后,进入hudi-cli说明成功:

[hadoop@hadoop1 hudi-0.12.0]$ pwd
/opt/soft/hudi-0.12.0
[hadoop@hadoop1 hudi-0.12.0]$ hudi-cli/hudi-cli.sh

 编译完成后,相关的包在packaging目录的各个模块中:

[hadoop@hadoop1 packaging]$ pwd
/opt/soft/hudi-0.12.0/packaging[hadoop@hadoop1 packaging]$ ls
hudi-aws-bundle           hudi-flink-bundle  hudi-hadoop-mr-bundle  hudi-integ-test-bundle     hudi-presto-bundle  hudi-timeline-server-bundle  hudi-utilities-bundle       README.md
hudi-datahub-sync-bundle  hudi-gcp-bundle    hudi-hive-sync-bundle  hudi-kafka-connect-bundle  hudi-spark-bundle   hudi-trino-bundle            hudi-utilities-slim-bundle

比如,flink与hudi的包

[hadoop@hadoop1 target]$ pwd
/opt/soft/hudi-0.12.0/packaging/hudi-flink-bundle/target[hadoop@hadoop1 target]$ ls
classes generated-sources hudi-flink1.13-bundle-0.12.0-sources.jar maven-shared-archive-resources original-hudi-flink1.13-bundle-0.12.0.jar rat.txt dependency-reduced-pom.xml  hudi-flink1.13-bundle-0.12.0.jar  maven-archiver maven-status                    original-hudi-flink1.13-bundle-0.12.0-sources.jar  test-classes

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/618571.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【每日小bug】mybatis plus id注解错误导致的问题

插入数据 id不为自增 指定了主键&#xff0c;没有指定自增。会导致出现 修改如上 报错 Data truncation: Out of range value for column ‘id’ at row 1 数据库是bigint&#xff0c;java中是Integer。 修改如上

Day28 17电话号码的字母组合 39组合求和 40组合求和II

17 电话号码的字母组合 给定一个仅包含数字 2-9 的字符串&#xff0c;返回所有它能表示的字母组合。 给出数字到字母的映射如下&#xff08;与电话按键相同&#xff09;。注意 1 不对应任何字母。 因为输入的数字的数量是不确定的&#xff0c;所以for循环的次数也是不确定的&…

重学Java 3 变量 数据类型转换 运算符

路上难免会有许多挫折&#xff0c;你要学会应对&#xff0c;要坚不可摧 ——24.1.12 一、常量 1.概述&#xff1a;在代码的运行过程中&#xff0c;值都不会发生改变的数据 2.分类&#xff1a; 整数常量&#xff1a;所有整数&#xff0c;包含正负 小数常量&#xff1a;所有带小数…

通过 Elastic Stack 充分利用电信领域生成式 AI 的力量

作者&#xff1a;Elastic Piotr Kobziakowski, Jrgen Obermann 在瞬息万变的电信领域&#xff0c;Elastic Stack 与生成式 AI 的集成正在开创运营效率和创新的新时代。 这些技术不仅增强了网络运营&#xff0c;而且还彻底改变了各个部门的内部流程。 下面&#xff0c;我们将深入…

嵌入式必备的WEB知识

写在前面 嵌入式要学习Wed前端吗&#xff1f;答案是要的&#xff0c;不需要深入学习&#xff0c;只需要简单了解即可。为什么要学习&#xff1f; 原因如下&#xff1a; 可以远程控制和管理设备&#xff1a;通过简单的Web知识&#xff0c;嵌入式系统可以建立Web界面&#xff0c…

【Effective Objective - C】—— 熟悉Objective-C

【Effective Objective - C】—— 熟悉Objective-C 熟悉Objective-C1.oc的起源消息和函数的区别运行期组件和内存管理要点&#xff1a; 2.在类的头文件中尽量少引入其他头文件向前声明要点&#xff1a; 3.多使用字面量语法&#xff0c;少用与之等价的方法字符串字面量字面数值字…

Java--业务场景:SpringBoot 通过Redis进行IP封禁实现接口防刷

文章目录 前言具体实现步骤1. 定义自定义注解2. 编写拦截器类IpUrlLimitInterceptor3. 在WebConfig类中添加IpUrlLimitInterceptor4. 添加注解到接口上 测试效果参考文章 前言 在实际项目中&#xff0c;有些攻击者会使用自动化工具来频繁刷新接口&#xff0c;造成系统的瞬时吞…

单因素方差分析--R

任务说明 三个剂量水平的药物处理受试者&#xff0c;每个剂量水平十个受试者&#xff0c;现在收集到数据后&#xff0c;问&#xff1a; 药物剂量水平显著影响受试者的response&#xff1f; 或者不同剂量药物处理受试者有显著效果的差异吗&#xff1f; 数据 library(tidyvers…

css选择器在python中如何使用

css选择器整理&#xff1a;https://blog.csdn.net/qq_40910788/article/details/84842951 目标&#xff1a;爬取某文章网站列表&#xff1a; 基础代码如下&#xff1a; import random import time import urllib.request import redef reptileTest(url):try:my_headers [&q…

Self-Attention

前置知识&#xff1a;RNN&#xff0c;Attention机制 在一般任务的Encoder-Decoder框架中&#xff0c;输入Source和输出Target内容是不一样的&#xff0c;比如对于英-中机器翻译来说&#xff0c;Source是英文句子&#xff0c;Target是对应的翻译出的中文句子&#xff0c;Attent…

Danswer部署指南

Quickstart How to deploy Danswer on your local machine ​ Requirements gitdocker with compose (docker version > 1.13.0) ​ Setup This quickstart guide covers setting up Danswer for local execution Clone the Danswer repo: git clone https://github.com…

Mysql 数据库ERROR 1820 (HY000): You must reset your password using ALTER USER 解决办法

Mysql 5.7数据库原来一直都能正常访问&#xff0c;突然访问不了&#xff0c;查看日志提示数据库需要修改密码&#xff0c; 具体解决办法如下操作&#xff1a; Windows 下&#xff1a; mysql的bin目录下&#xff0c; mysql>use mysql; mysql>mysql -uroot -p密码; 判…

gem5学习(14):将gem5扩展到ARM——Extending gem5 for ARM

目录 一、Downloading ARM Binaries 二、Building gem5 to run ARM Binaries 三、Modifying simple.py to run ARM Binaries 四、Running gem5 五、ARM Full System Simulation An aside on FS simulations 这个是gem5-learning中Getting Started的最后一篇文章&#xff…

imgaug库指南(20):从入门到精通的【图像增强】之旅

引言 在深度学习和计算机视觉的世界里&#xff0c;数据是模型训练的基石&#xff0c;其质量与数量直接影响着模型的性能。然而&#xff0c;获取大量高质量的标注数据往往需要耗费大量的时间和资源。正因如此&#xff0c;数据增强技术应运而生&#xff0c;成为了解决这一问题的…

各版本 操作系统 对 .NET Framework 与 .NET Core 支持

有两种类型的受支持版本&#xff1a;长期支持 (LTS) 版本和标准期限支持 (STS) 版本。 所有版本的质量都是一样的。 唯一的区别是支持的时间长短。 LTS 版本可获得为期三年的免费支持和补丁。 STS 版本可获得 18 个月的免费支持和修补程序。 有关详细信息&#xff0c;请参阅 .N…

Java重修第五天—面向对象2

通过学习本篇文章可以掌握如下知识 static&#xff1b;设计单例&#xff1b;继承。 之前文章我们已经对面向对象进行了入门学习&#xff0c;这篇文章我们就开始深入了解面向对象设计。 static 我们定义了一个 Student类&#xff0c;增加姓名属性&#xff1a;name &#xff1…

用通俗易懂的方式讲解:内容讲解+代码案例,轻松掌握大模型应用框架 LangChain

本文介绍了 LangChain 框架&#xff0c;它能够将大型语言模型与其他计算或知识来源相结合&#xff0c;从而实现功能更加强大的应用。 接着&#xff0c;对LangChain的关键概念进行了详细说明&#xff0c;并基于该框架进行了一些案例尝试&#xff0c;旨在帮助读者更轻松地理解 L…

最好的 8 个解锁 Android 手机的应用程序分析

如何解锁我的 Android 手机是一个困扰全球数百万人的问题。有多种Android解锁器可用于解锁手机。用户应确保选择最好的应用程序以轻松满意地完成工作。必须注意的是&#xff0c;数据在解锁手机的整个过程中都是安全可靠的。此类应用程序还应该能够在所有情况下检索数据。 锁屏移…

时间差异导致数据缺失,如何调整Grafana时间与Prometheus保持同步?

Grafana时间如何调快或调慢&#xff1f; 在k8s环境中&#xff0c;常使用prometheusgrafana做监控组件&#xff0c;prometheus负责采集、存储数据&#xff0c;grafana负责监控数据的可视化。 在实际的使用中&#xff0c;有时会遇到这样的问题&#xff0c;k8s集群中的时间比真实…

力扣:209.长度最小的子数组

1.题目分析&#xff1a; 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其总和大于等于 target 的长度最小的 连续子数组 [numsl, numsl1, ..., numsr-1, numsr] &#xff0c;并返回其长度。如果不存在符合条件的子数组&#xff0c;返回 0 。 示例 …