0 はじめに
Apache Hudi (Hadoop Upserts Delete and Incremental) は、次世代のストリーミング データ レイク プラットフォームです。Apache Hudi は、コアのウェアハウスとデータベースの機能をデータ レイクに直接もたらします。Hudi は、データのオープンソース ファイル形式を維持しながら、テーブル、トランザクション、効率的な更新/削除、高度なインデックス作成、ストリーミング インジェスト サービス、データ クラスタリング/圧縮の最適化、同時実行性を提供します。
Apache Hudi はストリーミング ワークロードに適しているだけでなく、効率的な増分バッチ処理パイプラインの作成も可能にします。
Apache Hudi は、あらゆるクラウド ストレージ プラットフォームで簡単に使用できます。Hudi の高度なパフォーマンス最適化により、Apache Spark、Flink、Presto、Trino、Hive などの一般的なクエリ エンジンの分析ワークロードが高速化されます。
1 環境の準備
1.1 Mavenをインストールする
Maven バージョン 3.3.1 以降が必要です
。setting.xml を変更し、Ali 倉庫のアドレスとして指定します。
<!-- 添加阿里云镜像-->
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
1.2 JDKのインストール
jdk8以降のバージョンが必要です
1.3 Git
主にhudiソースコードを取得するために使用されます。
1.4 hudi ソースコードをダウンロードする
https://github.com/apache/hudi/releases/
2 Hudi ソースコードのコンパイル
2.1 pom ファイルを変更する
hudi-0.12.0/pom.xml ファイルを変更します。
1) 新しいリポジトリを追加して、依存関係のあるダウンロードを高速化します。
<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 バージョンは 2.10.1)。ハイブのデフォルトのバージョンは 2.3.1 です。使用している現在のバージョンに変更してください。
2.2 コードを変更する
Hudi はデフォルトで hadoop2 に依存します。hadoop3 と互換性を持たせるには、バージョンの変更に加えて、次のコードを変更する必要があります:
hudi-0.12.0/hudi-common/src/main/java/org/apache/hudi/ common/table/log/block/ それ以外の場合、HoodieParquetDataBlock.java は
hadoop2.x および 3.x バージョンと互換性があります。
2.3 Kafka の依存関係を変更する
手動でインストールする必要がある Kafka 依存関係がいくつかあります。手動でインストールしないと、次のようなコンパイル エラーが発生します。
1) jar パッケージをダウンロードします。
URL からダウンロードします。 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
2) 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
2.4 Spark モジュールの依存関係の競合の解決
Hive バージョンは 3.1.0 に変更され、それに対応する Jetty は 0.9.3 で、hudi 自体は 0.9.4 を使用します。依存関係の競合があります。 1
) hudi-spark-bundle の pom ファイルを変更し、低バージョンの Jetty を除外します。 、指定されたバージョンの hudi Jetty を追加します。hudi
-0.12.0/packaging/hudi-spark-bundle/pom.xml
は 280 行目にあり、次の内容を追加します。
<!-- 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>
ハイブサービス
hive-jdbc
hive-metastore
hive-common
は最後に追加されます。
2) hudi-utilities-bundle の pom ファイルを変更し、下位バージョンの Jetty を除外し、hudi で指定されたバージョンの Jetty を追加します: hudi
-0.12.0/パッケージング/hudi-utilities-bundle/pom.xml
<!-- 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>
hive-service
hive-jdbc
hive-metastore
hive-common
新しいコンテンツ
2.5 コンパイルの実行
mvn clean package -DskipTests -Dspark3.2 -Dflink1.13 -Dscala-2.12 -Dhadoop.version=3.1.1 -Pflink-bundle-shade-hive3
注: ここでは、spark/flink コンポーネントのバージョンは -D パラメーターで指定され、scala のバージョンは指定されます
3 検証
コンパイルが成功したら、「hudi-cli」と入力して成功を示します。
コンパイルが完了すると、関連するパッケージがパッケージング ディレクトリの各モジュールに配置されます。