更新时间:2024-11-06 GMT+08:00
Hadoop jar包冲突,导致Flink提交失败
问题现象
Flink 提交失败,异常为:
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: Class org.apache.hadoop.fs.obs.metrics.OBSAMetricsProvider not found at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2664) at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2688) ... 31 common frames omitted Caused by: java.lang.ClassNotFoundException: Class org.apache.hadoop.fs.obs.metrics.OBSAMetricsProvider not found at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:2568) at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2662) ... 32 common frames omitted
原因分析
Flink jar包冲突。用户提交的flink jar 与 DLI 集群中的hdfs jar包存在冲突。
处理步骤
- 1. 将用户pom文件中的的hadoop-hdfs设置为:
<dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-hdfs</artifactId> <version>${hadoop.version}</version> <scope> provided </scope> </dependency>
或使用exclusions标签将其排除关联。
- 若使用到hdfs的配置文件,则需要将core-site.xml、hdfs-site.xml、yarn-site.xml 修改为mrs-core-site.xml、mrs-hdfs-site.xml、mrs-hbase-site.xml
conf.addResource(HBaseUtil.class.getClassLoader().getResourceAsStream("mrs-core-site.xml"), false); conf.addResource(HBaseUtil.class.getClassLoader().getResourceAsStream("mrs-hdfs-site.xml"), false); conf.addResource(HBaseUtil.class.getClassLoader().getResourceAsStream("mrs-hbase-site.xml"), false);
父主题: Flink Jar作业类