【FLINK】 No Executor found. Please make sure to export the HADOOP_CLASSPATH

背景:

为了更好的使用flink sql&table,系统决定从flink 从1.10 升级到 1.11,然后在测试flink example的命令时出现了这个bug

(不懂怎么安装的直接参考官网链接:Apache Flink 1.11 Documentation: Local Installation

java.lang.IllegalStateException: No Executor found. Please make sure to export the HADOOP_CLASSPATH environment variable or have hadoop in your classpath.
 For more information refer to the "Deployment & Operations" section of the official 
 Apache Flink documentation. at org.apache.flink.yarn.cli.FallbackYarnSessionCli.isActive(FallbackYarnSessionCli.java:59) at 
 org.apache.flink.client.cli.CliFrontend.validateAndGetActiveCommandLine(CliFrontend.java:1090) at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:218) at 
 org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:916) at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:992) at 
 org.apache.flink.runtime.security.contexts.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:30) at 
 org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:992)

原因:

产生这个问题的原因这个,具体的意思就是从Flink 1.11开始,flink-shaded-hadoop-2-uberFlink项目不再正式支持使用发行版。建议用户通过提供Hadoop依赖关系HADOOP_CLASSPATH(请参见上文),官方(https://ci.apache.org/projects/flink/flink-docs-stable/ops/deployment/hadoop.html)Apache Flink 1.11 Documentation: Hadoop Integration针对这个问题有详细的说明见如下:

Starting from Flink 1.11, using flink-shaded-hadoop-2-uber releases is not officially supported by the Flink project anymore. Users are advised to provide Hadoop dependencies through HADOOP_CLASSPATH (see above).

Hadoop Integration

Providing Hadoop classes

In order to use Hadoop features (e.g., YARN, HDFS) it is necessary to provide Flink with the required Hadoop classes, as these are not bundled by default.

The recommended approach is adding the Hadoop classpath to Flink through the HADOOP_CLASSPATH environment variable.

Flink will use the environment variable HADOOP_CLASSPATH to augment the classpath that is used when starting Flink components such as the Client, JobManager, or TaskManager. Most Hadoop distributions and cloud environments will not set this variable by default so if the Hadoop classpath should be picked up by Flink the environment variable must be exported on all machines that are running Flink components.

When running on YARN, this is usually not a problem because the components running inside YARN will be started with the Hadoop classpaths, but it can happen that the Hadoop dependencies must be in the classpath when submitting a job to YARN. For this, it’s usually enough to run

export HADOOP_CLASSPATH=`hadoop classpath`

in the shell. Note that hadoop is the hadoop binary and that classpath is an argument that will make it print the configured Hadoop classpath. The classpath returned by hadoop classpath also includes the Hadoop configuration directories.

If you are manually assembling the HADOOP_CLASSPATH variable, we recommend adding the Hadoop configuration directories as well.

Running a job locally

To run a job locally as one JVM process using the mini cluster, the required hadoop dependencies have to be explicitly added to the classpath of the started JVM process.

To run an application using Maven (also from IDE as a Maven project), the required Hadoop dependencies can be added as provided to the pom.xml, e.g.:

<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-client</artifactId>
    <version>2.8.3</version>
    <scope>provided</scope>
</dependency>

This way it should work both in local and cluster mode where the provided dependencies are added elsewhere as described before.

To run or debug an application in IntelliJ Idea the provided dependencies can be included to the class path in the “Run|Edit Configurations” window.

Warning: Starting from Flink 1.11, using flink-shaded-hadoop-2-uber releases is not officially supported by the Flink project anymore. Users are advised to provide Hadoop dependencies through HADOOP_CLASSPATH (see above).

The Flink project used to (until Flink 1.10) release Hadoop distributions for specific versions, that relocate or exclude several dependencies to reduce the risk of dependency clashes. These can be found in the Additional Components section of the download page. For these versions it is sufficient to download the corresponding Pre-bundled Hadoop component and putting it into the /lib directory of the Flink distribution.

If the used Hadoop version is not listed on the download page (possibly due to being a Vendor-specific version), then it is necessary to build flink-shaded against this version. You can find the source code for this project in the Additional Components section of the download page.

Note If you want to build flink-shaded against a vendor specific Hadoop version, you first have to configure the vendor-specific maven repository in your local maven setup as described here.

Run the following command to build and install flink-shaded against your desired Hadoop version (e.g., for version 2.6.5-custom):

mvn clean install -Dhadoop.version=2.6.5-custom

After this step is complete, put the flink-shaded-hadoop-2-uber jar into the /lib directory of the Flink distribution.

解决思路:


参考下面链接:[FLINK-19126] Failed to run job in yarn-cluster mode due to No Executor found. - ASF JIRA

注意啦注意啦,在这里我做了个ZZ的骚操作!!!!

在这里别自己想太多,一开始我理解这个命令是 export HADOOP_CLASSPATH=hadoop的文件路径,就这样运行了

export HADOOP_CLASSPATH=/usr/local/hadoop

发现一点作用的都没起,其实直接运行这个命令就可以了不需要改任何东西,马上就不报错了

 export HADOOP_CLASSPATH=`hadoop classpath`

后续:

其实hadoop classpath 命令就是把有关于hadoop的环境全部加载出来

hadoop classpath

  • 9
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 16
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Zsigner

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值