基于CDH6环境编译Hudi090IDEA编译
各组件版本
- Hive版本:2.1.1-cdh6.3.2
- Hadoop版本:3.0.0-cdh6.3.2
- Spark版本:2.4.0-cdh6.3.2
- Flink版本:1.12.2
- Hudi版本:0.9.0
- Scala版本:2.11
- Kafka版本:2.2.1
1.1 Hudi代码下载编译

1.12 修改pom.xml配置文件
确认<repositories></repositories>部分是否有Cloudera的Maven源:
xml
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>confluent</id>
<url>https://packages.confluent.io/maven/</url>
</repository>
<repository>
<id>pentaho.org</id>
<url>https://public.nexus.pentaho.org/repository/proxy-public-3rd-party-release/</url>
</repository>
1.13 修改<properties></properties>部分
修改hadoop.version、hive.version以及spark2.version的版本:
xml
<hadoop.version>3.0.0-cdh6.3.2</hadoop.version>
<hive.groupid>org.apache.hive</hive.groupid>
<hive.version>2.1.1-cdh6.3.2</hive.version>
<flink.version>1.12.2</flink.version>
<spark2.version>2.4.0-cdh6.3.2</spark2.version>
1.14 修改hive-jdbc和hive-service两个依赖的配置,添加排除

2.1 修改hudi-spark模块的org.apache.hudi.DefaultSource类中的部分代码段


2.2 hudi-utilities模块代码修改
-
org.apache.hudi.utilities.sources.helpers.CloudObjectsSelector类中的getFileAttributesFromRecord(JSONObject record)方法,该方法未抛出JSONException,导致编译失败。
-
org.apache.hudi.utilities.sources.helpers.S3EventsMetaSelector类中processAndDeleteInvalidMessages方法添加JSONException异常抛出。
-
org.apache.hudi.utilities.sources.helpers.TestS3EventsMetaSelector类中testNextEventsFromQueueShouldReturnsEventsFromQueue方法添加JSONException异常抛出。
-
org.apache.hudi.utilities.sources.helpers.S3EventsMetaSelector类中getValidEvents、processAndDeleteInvalidMessages方法添加JSONException异常抛出。
-
org.apache.hudi.utilities.sources.helpers.CloudObjectsSelector类中的getFileAttributesFromRecord方法添加JSONException异常抛出。
2.3 hudi-spark-datasource/hudi-spark-common模块的org.apache.hudi.DataSourceReadOptions,将如下截图部分代码注释(204-228行的if判断)

2.4 hudi-integ-test模块代码修改,注释pom.xml文件中jackson-annotations依赖的scope

2.5 hudi-hadoop-mr模块代码修改
org.apache.hudi.hadoop.functional.TestHoodieCombineHiveInputFormat类中的HAS_MAP_WORK异常报错。


3.1 编译打包
bash
mvn clean install -DskipTests -DskipITs -Dcheckstyle.skip=true -Drat.skip=true -Dspark2.4 -Dscala-2.11 -Dhadoop.version=3.0.0 -Pflink-bundle-shade-hive2
3.2 手动安装Kafka依赖
有几个Kafka的依赖需要手动安装,否则编译报错如下:

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

2)install到maven本地仓库
bash
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
3.2 报错:Command execution failed. Cannot run program "inash" (in directory "D:githubhudihudi-integ-test")
bash
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (Setup HUDI_WS) on project hudi-integ-test: Command execution failed. Cannot run program "inash" (in directory "D:githubhudihudi-integ-test"): CreateProcess error=2, 系统找不到指定的文件。 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :hudi-integ-test
修改 D:githubhudipom.xml 根pom文件:
xml
<modules>
<module>hudi-common</module>
<module>hudi-cli</module>
<module>hudi-client</module>
<module>hudi-hadoop-mr</module>
<module>hudi-spark</module>
<module>hudi-timeline-service</module>
<module>hudi-utilities</module>
<module>hudi-sync</module>
<module>packaging/hudi-hadoop-mr-bundle</module>
<module>packaging/hudi-hive-sync-bundle</module>
<module>packaging/hudi-spark-bundle</module>
<module>packaging/hudi-presto-bundle</module>
<module>packaging/hudi-utilities-bundle</module>
<module>packaging/hudi-timeline-server-bundle</module>
<module>docker/hoodie/hadoop</module>
<!-- <module>hudi-integ-test</module> -->
<!-- <module>packaging/hudi-integ-test-bundle</module> -->
<module>hudi-examples</module>
<module>hudi-flink</module>
<module>packaging/hudi-flink-bundle</module>
</modules>
4. 编译成功结果查看


5. 常见其它编译报错
编译报错处理
-
Too many files with unapproved license:如果报license错误,由于内部使用,可添加参数
-Drat.skip=true暂时跳过,例如:bashmvn deploy -DskipTests -Drat.skip=true -
缺少pentaho-aggdesigner-algorithm:
bash[ERROR] Failed to execute goal on project hudi-hadoop-mr: Could not resolve dependencies for project org.apache.hudi:hudi-hadoop-mr:jar:0.9.0-SNAPSHOT: Could not find artifact org.pentaho:pentaho-aggdesigner-algorithm:jar:5.1.5-jhyde in nexus此包在由http://repo.spring.io/plugins-release/仓库发布。当前直接添加报401权限问题,可添加阿里云的代理仓库地址https://maven.aliyun.com/repository/spring-plugin解决。
-
缺少kafka-avro-serializer:
bash[ERROR] Failed to execute goal on project hudi-utilities_2.11: Could not resolve dependencies for project org.apache.hudi:hudi-utilities_2.11:jar:0.9.0-SNAPSHOT: The following artifacts could not be resolved: io.confluent:kafka-avro-serializer:jar:3.0.0, io.confluent:common-config:jar:3.0.0, io.confluent:common-utils:jar:3.0.0, io.confluent:kafka-schema-registry-client:jar:3.0.0: Could not find artifact io.confluent:kafka-avro-serializer:jar:3.0.0 in nexus (http://192.168.129.111:8081/repository/tydic-public-repositories/)增加仓库:
xml<repositories> <repository> <id>confluent</id> <url>http://packages.confluent.io/maven/</url> </repository> </repositories>
参考链接:
https://blog.csdn.net/weixin_46389691/article/details/128276527

end
