flink clickhouse-jdbc和flink-connector 写入数据到clickhouse因为jar包冲突导致的60 seconds.Please check if the requested resources are available in the YARN cluster和Could not resolve ResourceManager address akka报错血案

时间:2021-08-14
本文章向大家介绍flink clickhouse-jdbc和flink-connector 写入数据到clickhouse因为jar包冲突导致的60 seconds.Please check if the requested resources are available in the YARN cluster和Could not resolve ResourceManager address akka报错血案,主要包括flink clickhouse-jdbc和flink-connector 写入数据到clickhouse因为jar包冲突导致的60 seconds.Please check if the requested resources are available in the YARN cluster和Could not resolve ResourceManager address akka报错血案使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

一、问题现象,使用flink on yarn 模式,写入数据到clickhouse,但是在yarn 集群充足的情况下一直报:Deployment took more than 60 seconds. Please check if the requested resources are available in the YARN cluster,表面现象是 yarn 集群资源可能不够,实际yarn 集群资源是够用的。

查看flink jobmanager的日志,发现日志中一直在出现如下报错:

Could not resolve ResourceManager address akka.tcp://flink@xxxxxxxxx.cn:38121/user/rpc/resourcemanager_*, retrying in 10000 ms: Could not connect to rpc endpoint under address akka.tcp://xxxxxxx.cn:38121/user/rpc/resourcemanager_*.

从这个日志来看,也就基本可以确定不是yarn集群资源的问题,是yarn 集群通信出现了问题。

1)、交叉验证,发现提交别的flink streamling 任务都不会存在该问题,只有写clickhouse的时候才会出现该问题,初步排除可能是代码问题或者该任务的jar包引起的。

2)、查看pom依赖:

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-connector-jdbc_2.11</artifactId>
            <version>${flink.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-streaming-java_2.11</artifactId>
            <version>${flink.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-connector-kafka_2.11</artifactId>
            <version>${flink.version}</version>
      </dependency>
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-java</artifactId>
            <version>${flink.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>ru.yandex.clickhouse</groupId>
            <artifactId>clickhouse-jdbc</artifactId>
            <version>${clickhouse-jdbc.version}</version>
       </dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
</dependency>

从日志中虽然看不出明显的jar包冲突问题,但是依然能从Could not resolve ResourceManager address akka.tcp://flink@xxxxxxxxx.cn:38121/user/rpc/resourcemanager_*, retrying in 10000 ms: Could not connect to rpc endpoint under address akka.tcp://xxxxxxx.cn:38121/user/rpc/resourcemanager_*. 联想到可能是jar冲突或者jar包版本导致的冲突,导致 connect 失败。

联想到hadoop 环境中,最容易出现冲突的包,如下所示,首先去排查。

                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>

  然后发现,果然clickhouse-jdbc中存在这个包,如下所示

 在pom中排除该包,如下所示

        <dependency>
            <groupId>ru.yandex.clickhouse</groupId>
            <artifactId>clickhouse-jdbc</artifactId>
            <version>${clickhouse-jdbc.version}</version>
            <exclusions>
            <exclusion>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
            </exclusion>
            </exclusions>
        </dependency>

重新运行,问题得到解决。

二、问题启示:

1、所有的日志中没有地方显示代码冲突,表层现象为Could not resolve ResourceManager address akka.tcp://flink@xxxxxxxxx.cn:38121/user/rpc/resourcemanager_*, retrying in 10000 ms: Could not connect to rpc endpoint under address akka.tcp://xxxxxxx.cn:38121/user/rpc/resourcemanager_*. 很难联想到jar包冲突,后来灵感来源于

https://blog.csdn.net/qq_31957747/article/details/108883793   这个篇博文,虽然发生冲突的jar是不一样,但是问题很类似,所以朝这个方向去做了尝试。发现jar包冲突,真的可能会带来这个问题。

2、flink on yarn 模式中,最容易出现flink任务的jar包和hadoop集群中的jar包冲突。 在写代码的时候,一般pom中可能是检测不出来的,因为很多包不直接依赖。但是在flink run -m yarn-cluster 提交任务时,却会使用到hadoop lib 下的classpath。 所以这种冲突代码中很难检测,实际中却很容易出现。

3、不要被表面的现象迷惑,要能根据现象去看到本质,这样才能解决到问题。

作者的原创文章,转载须注明出处。原创文章归作者所有,欢迎转载,但是保留版权。对于转载了博主的原创文章,不标注出处的,作者将依法追究版权,请尊重作者的成果。

原文地址:https://www.cnblogs.com/laoqing/p/15140668.html