前言
如题:记录一个 Hudi HBase 依赖冲突问题及解决方案
版本
Hudi 0.13.0
Spark 3.2.3
异常
ERROR Javalin: Exception occurred while servicing http-request
java.util.concurrent.CompletionException: java.lang.NoSuchMethodError: org.apache.hadoop.hdfs.client.HdfsDataInputStream.getReadStatistics()Lorg/apache/hadoop/hdfs/DFSInputStream$ReadStatistics;
Caused by: java.lang.NoSuchMethodError: org.apache.hadoop.hdfs.client.HdfsDataInputStream.getReadStatistics()Lorg/apache/hadoop/hdfs/DFSInputStream$ReadStatistics;
复现
create table test.test_hudi_table (
id int,
name string,
price double,
ts long,
dt string
) using hudi
partitioned by (dt)
options (
type = 'cow',
primaryKey = 'id',
preCombineField = 'ts',
hoodie.cleaner.commits.retained = '1'
);
insert into test.test_hudi_table values (1,'hudi',10,100,'2024-05-31');
insert into test.test_hudi_table values (2,'hudi',20,200,'2024-05-31');
insert into test.test_hudi_table values (3,'hudi',30,300,'2024-05-31');
insert into test.test_hudi_table values (4,'hudi',40,400,'2024-05-31');
insert into test.test_hudi_table values (5,'hudi',50,500,'2024-05-31');
insert into test.test_hudi_table values (6,'hudi',60,600,'2024-05-31');
insert into test.test_hudi_table values (7,'hudi',70,700,'2024-05-31');
备注:参数:hoodie.cleaner.commits.retained = '1', 是为了更快的复现异常。

详细异常
https://note.youdao.com/s/KkK2m0yR
原因
1、hudi 0.13.0 默认启用 metadata table,之前的版本默认不启用。(HoodieMetadataConfig
)
2、metadata table 使用HBase的HFile格式存储
3、Hudi 依赖 HBASE 2.4.9, HBase 2.4.9 默认依赖 Hadoop 2.x。与我们使用的Hadoop 3.x版本不一致,存在兼容问题,导致依赖冲突:NoSuchMethodError。
解决方法
临时方案
可以先不开启 metadata table
hoodie.metadata.enable=false
create table test.test_hudi_table (
id int,
name string,
price double,
ts long,
dt string
) using hudi
partitioned by (dt)
options (
type = 'cow',
primaryKey = 'id',
preCombineField = 'ts',
hoodie.metadata.enable=false,
hoodie.cleaner.commits.retained = '1'
);

永久方案
重新编译
具体方法为:
1、先编译HBase,编译时指定 Hadoop 3版本,install 本地
2、然后重新打包Hudi
hbase 编译
git clone https://github.com/apache/hbase.git
cd hbase/
git checkout rel/2.4.9
mvn clean install -DskipTests -Dhadoop.profile=3.0
备注:由于该冲突依赖类对应的模块为hbase-server,所以在win上编译最后几个模块失败不影响,可以忽略,如果想全部编译通过,可以在Linux上
hudi编译
1、下载 hudi源码,切换到 release-0.13.0 分支
mvn clean package -DskipTests -Dscala-2.12 -Dspark3.2
2、window编译失败问题可参考:Hudi master 0.13.0-SNAPSHOT Win10 打包异常解决
3、对应的hudi包路径:
hudi\packaging\hudi-spark-bundle\target
hudi\packaging\hudi-utilities-bundle\target
验证

相关阅读
🧐 分享、点赞、在看,给个3连击呗!👇
文章转载自伦少的博客,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




