草庐IT

Hudi(2):Hudi的编译和安装

电光闪烁 2023-04-20 原文

目录

0. 相关文章链接

1. 编译环境准备

2. 上传Hudi源码包并修改pom文件

3. 修改源码兼容hadoop3

4. 手动安装Kafka依赖

5. 解决spark模块依赖冲突

5.1. 修改hudi-spark-bundle的pom文件

5.2. 修改hudi-utilities-bundle的pom文件

6. 编译并进入Hudi客户端

7. Hudi集成Spark的环境准备

7.1. Hudi支持的Spark版本

7.2. 集成Spark

8. Hudi集成Flink的环境准备

8.1. Hudi支持的Flink版本

9. Hudi集成Hive

9.1. 拷贝编译好的jar包

9.2. 配置完后重启 hive


0. 相关文章链接

 Hudi文章汇总 

1. 编译环境准备

  • 相关组件版本如下:
Hadoop3.1.3
Hive3.1.2
Flink1.13.6,scala-2.12
Spark3.2.2,scala-2.12

2. 上传Hudi源码包并修改pom文件

  • 上传源码包:
# 将hudi-0.12.0.src.tgz上传到/opt/software,并解压:
tar -zxvf /opt/software/hudi-0.12.0.src.tgz -C /opt/software

# github地址:https://github.com/apache/hudi/
  • 在pom文件中新增repository加速依赖下载:
# 编辑pom文件
vim /opt/software/hudi-0.12.0/pom.xml

# 新增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>
  • 在pom文件中修改依赖的组件版本:
<hadoop.version>3.1.3</hadoop.version>
<hive.version>3.1.2</hive.version>

3. 修改源码兼容hadoop3

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

vim /opt/software/hudi-0.12.0/hudi-common/src/main/java/org/apache/hudi/common/table/log/block/HoodieParquetDataBlock.java

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

否则会因为hadoop2.x和3.x版本兼容问题(找不到合适的FSDataOutputStream构造器)。

4. 手动安装Kafka依赖

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

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

# 解压后找到以下jar包,上传编译服务器
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
  • install到maven本地仓库
mvn install:install-file -DgroupId=io.confluent -DartifactId=common-config -Dversion=5.3.4 -Dpackaging=jar -Dfile=./common-config-5.3.4.jar
mvn install:install-file -DgroupId=io.confluent -DartifactId=common-utils -Dversion=5.3.4 -Dpackaging=jar -Dfile=./common-utils-5.3.4.jar
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
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

5. 解决spark模块依赖冲突

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

5.1. 修改hudi-spark-bundle的pom文件

目的:排除低版本jetty,添加hudi指定版本的jetty

pom文件位置:vim /opt/software/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

5.2. 修改hudi-utilities-bundle的pom文件

目的:排除低版本jetty,添加hudi指定版本的jetty

位置:vim /opt/software/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的错误。

6. 编译并进入Hudi客户端

  • 编译命令:
mvn clean package -DskipTests -Dspark3.2 -Dflink1.13 -Dscala-2.12 -Dhadoop.version=3.1.3 -Pflink-bundle-shade-hive3
  • 进入hudi-cli说明成功:

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

7. Hudi集成Spark的环境准备

7.1. Hudi支持的Spark版本

Hudi

Supported Spark 3 version

0.12.x

3.3.x,3.2.x,3.1.x

0.11.x

3.2.x(default build, Spark bundle only),3.1.x

0.10.x

3.1.x(default build), 3.0.x

0.7.0-0.9.0

3.0.x

0.6.0 and prior

Not supported

 注意:0.11.x不建议使用,如果要用请使用补丁分支:[DO NOT MERGE] 0.11.1 release patch branch by danny0405 · Pull Request #6182 · apache/hudi · GitHub

7.2. 集成Spark

其实就是将上述编译好的安装包拷贝到spark下的jars目录中:

cp /opt/software/hudi-0.12.0/packaging/hudi-spark-bundle/target/hudi-spark3.2-bundle_2.12-0.12.0.jar /opt/module/spark-3.2.2/jars

注意:启动Spark之前需要启动Hadoop等相关组件。

8. Hudi集成Flink的环境准备

8.1. Hudi支持的Flink版本

Hudi

Supported Flink version

0.12.x

1.15.x、1.14.x、1.13.x

0.11.x

1.14.x、1.13.x

0.10.x

1.13.x

0.9.0

1.12.2

注意:0.11.x不建议使用,如果要用请使用补丁分支:[DO NOT MERGE] 0.11.1 release patch branch by danny0405 · Pull Request #6182 · apache/hudi · GitHub

  • 将上述编译好的安装包拷贝到flink下的jars目录中:
cp /opt/software/hudi-0.12.0/packaging/hudi-flink-bundle/target/hudi-flink1.13-bundle_2.12-0.12.0.jar /opt/module/flink-1.13.6/lib/
  • 拷贝guava包,解决依赖冲突
cp /opt/module/hadoop-3.1.3/share/hadoop/common/lib/guava-27.0-jre.jar /opt/module/flink-1.13.6/lib/
  • 配置Hadoop环境变量
sudo vim /etc/profile.d/my_env.sh

export HADOOP_CLASSPATH=`hadoop classpath`
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop

source /etc/profile.d/my_env.sh

注意:启动Flink之前需要启动Hadoop等相关组件。

9. Hudi集成Hive

        Hudi 源表对应一份 HDFS 数据,通过 Spark,Flink 组件或者 Hudi CLI,可以将 Hudi 表的数据映射为 Hive 外部表,基于该外部表, Hive可以方便的进行实时视图,读优化视图以及增量视图的查询。

注意:以 hive3.1.2、hudi 0.12.0为例,其他版本类似。

9.1. 拷贝编译好的jar包

将 hudi-hadoop-mr-bundle-0.12.0.jar , hudi-hive-sync-bundle-0.12.0.jar 放到 hive 节点的lib目录下:

cp /opt/software/hudi-0.12.0/packaging/hudi-hadoop-mr-bundle/target/hudi-hadoop-mr-bundle-0.12.0.jar /opt/module/hive/lib/

cp /opt/software/hudi-0.12.0/packaging/hudi-hive-sync-bundle/target/hudi-hive-sync-bundle-0.12.0.jar /opt/module/hive/lib/

9.2. 配置完后重启 hive

// 按照需求选择合适的方式重启
nohup hive --service metastore &
nohup hive --service hiveserver2 &

注意:启动Hive之前需要启动Hadoop等相关组件。


注:其他Hudi相关文章链接由此进 ->  Hudi文章汇总 


有关Hudi(2):Hudi的编译和安装的更多相关文章

  1. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

  2. ruby - 完全离线安装RVM - 2

    我打算为ruby​​脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn

  3. ruby-on-rails - rails 目前在重启后没有安装 - 2

    我有一个奇怪的问题:我在rvm上安装了ruby​​onrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(

  4. ruby - 如何为 emacs 安装 ruby​​-mode - 2

    我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby​​提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs

  5. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  6. ruby - 通过 RVM (OSX Mountain Lion) 安装 Ruby 2.0.0-p247 时遇到问题 - 2

    我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search

  7. ruby - 如何在 Lion 上安装 Xcode 4.6,需要用 RVM 升级 ruby - 2

    我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121

  8. ruby - Fast-stemmer 安装问题 - 2

    由于fast-stemmer的问题,我很难安装我想要的任何ruby​​gem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=

  9. ruby - 安装 Ruby 时遇到问题(无法下载资源 "readline--patch") - 2

    当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub

  10. ruby - 通过 RVM 安装 Ruby 1.9.2 永远行不通! - 2

    当我执行>rvminstall1.9.2时一切顺利。然后我做>rvmuse1.9.2也很顺利。但是当涉及到ruby​​-v时..sam@sjones:~$rvminstall1.9.2/home/sam/.rvm/rubies/ruby-1.9.2-p136,thismaytakeawhiledependingonyourcpu(s)...ruby-1.9.2-p136-#fetchingruby-1.9.2-p136-#downloadingruby-1.9.2-p136,thismaytakeawhiledependingonyourconnection...%Total%Rece

随机推荐