Flink on yarn 常见错误

本文列举了Flink在YARN上运行时常见的五种错误:1) 连接ResourceManager失败,建议先启动Hadoop环境;2) 无法获取ClusterClient状态,可能因资源不足,可通过关闭Hadoop虚拟内存检查或减少分配内存解决;3) 用户函数实例化失败,增大Flink启动资源参数可解决;4) Akka配置变量解析失败,需在maven-shaded-plugin中配置;5) NoClassDefFoundError,可能是类路径冲突,检查并清理YARN的lib目录。

1 Retrying connect to server

Flink on yarn 依赖 hadoop 集群,在没有启动hadoop之前,直接执行Flink启动命令

./bin/yarn-session.sh -n 1 -jm 1024 -tm 4096

结果就是flink连不上ResourceManager,脚本一直卡在着进行重试

2018-05-19 14:36:08,062 INFO  org.apache.hadoop.yarn.client.RMProxy - Connecting to ResourceManager at /0.0.0.0:8032  
2018-05-19 14:36:09,231 INFO  org.apache.hadoop.ipc.Client - Retrying connect to server: 0.0.0.0/0.0.0.0:8032. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)  
2018-05-19 14:36:10,234 INFO  org.apache.hadoop.ipc.Client - Retrying connect to server: 0.0.0.0/0.0.0.0:8032. Already tried 1 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)  
2018-05-19 14:36:11,235 INFO  org.apache.hadoop.ipc.Client - Retrying connect to server: 0.0.0.0/0.0.0.0:8032. Already tried 2 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)  
2018-05-19 14:36:12,238 INFO  org.apache.hadoop.ipc.Client - Retrying connect to server: 0.0.0.0/0.0.0.0:8032. Already tried 3 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)  
2018-05-19 14:36:13,240 INFO  org.apache.hadoop.ipc.Client - Retrying connect to server: 0.0.0.0/0.0.0.0:8032. Already tried 4 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)  
2018-05-19 14:36:14,247 INFO  org.apache.hadoop.ipc.Client - Retrying connect to server: 0.0.0.0/0.0.0.0:8032. Already tried 5 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)  

所以,先别着急,启动好 hadoop 环境后再启动Flink。

2 Unable to get ClusterClient status from Application Client

hadoop 已经启动了,这下执行 Flink 启动命令

./bin/yarn-session.sh -n 1 -jm 1024 -tm 4096

Flink 还是没有启动成功

2018-05-19 15:30:10,456 WARN  akka.remote.ReliableDeliverySupervisor                        - Association with remote system [akka.tcp://flink@hadoop100:55053] has failed, address is now gated for [5000] ms. Reason: [Disassociated] 
2018-05-19 15:30:21,680 WARN  org.apache.flink.yarn.cli.FlinkYarnSessionCli                 - Could not retrieve the current cluster status. Skipping current retrieval attempt ...
java.lang.RuntimeException: Unable to get ClusterClient status from Application Client
        at org.apache.flink.yarn.YarnClusterClient.getClusterStatus(YarnClusterClient.java:253)
        at org.apache.flink.yarn.cli.FlinkYarnSessionCli.runInteractiveCli(FlinkYarnSessionCli.java:443)
        at org.apache.flink.yarn.cli.FlinkYarnSessionCli.run(FlinkYarnSessionCli.java:720)
        at org.apache.flink.yarn.cli.FlinkYarnSessionCli$1.call(FlinkYarnSessionCli.java:514)
        at org.apache.flink.yarn.cli.FlinkYarnSessionCli$1.call(FlinkYarnSessionCli.java:511)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1698)
        at org.apache.flink.runtime.security.HadoopSecurityContext.runSecured(HadoopSecurityContext.java:41)
        at org.apache.flink.yarn.cli.FlinkYarnSessionCli.main(FlinkYarnSessionCli.java:511)
Caused by: org.apache.flink.util.FlinkException: Could not connect to the leading JobManager. Please check that the JobManager is running.
        at org.apache.flink.client.program.ClusterClient.getJobManagerGateway(ClusterClient.java:862)
        at org.apache.flink.yarn.YarnClusterClient.getClusterStatus(YarnClusterClient.java:248)
        ... 9 more
Caused by: org.apache.flink.runtime.leaderretrieval.LeaderRetrievalException: Could not retrieve the leader gateway.
        at org.apache.flink.runtime.util.LeaderRetrievalUtils.retrieveLeaderGateway(LeaderRetrievalUtils.java:79)
        at org.apache.flink.client.program.ClusterClient.getJobManagerGateway(ClusterClient.java:857)
        ... 10 more
Caused by: java.util.concurrent.TimeoutException: Futures timed out after [10000 milliseconds]
        at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:223)
        at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:227)
        at scala.concurrent.Await$$anonfun$result$1.apply(package.scala:190)
        at scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53)
        at scala.concurrent.Await$.result(package.scala:190)
        at scala.concurrent.Await.result(package.scala)
        at org.apache.flink.runtime.util.LeaderRetrievalUtils.retrieveLeaderGateway(LeaderRetrievalUtils.java:77)
        ... 11 more
2018-05-19 15:30:21,691 WARN  org.apache.flink.yarn.YarnClusterClient                       - YARN reported application state FAILED
2018-05-19 15:30:21,692 WARN  org.apache.flink.yarn.YarnClusterClient                       - Diagnostics: Application application_1521277661809_0006 failed 1 times due to AM Container for appattempt_1521277661809_0006_000001 exited with  exitCode: -103
For more detailed output, check application tracking page:http://hadoop100:8088/cluster/app/application_1521277661809_0006Then, click on links to logs of each attempt.
Diagnostics: Container [pid=6386,containerID=container_1521277661809_0006_01_000001] is running beyond virtual memory limits. Current usage: 250.5 MB of 1 GB physical memory used; 2.2 GB of 2.1 GB virtual memory used. Killing container.
Dump of the process-tree for container_1521277661809_0006_01_000001 :
        |- PID PPID PGRPID SESSID CMD_NAME USER_MODE_TIME(MILLIS) SYSTEM_TIME(MILLIS) VMEM_USAGE(BYTES) RSSMEM_USAGE(PAGES) FULL_CMD_LINE
    
<think>嗯,用户想了解如何在YARN上部署Flink,也就是Flink on YARN的部署教程。我需要根据提供的引用内容,整理出一个清晰的步骤指南。首先,我应该先确认用户的需求是什么。他们可能是一个刚开始接触Flink的大数据工程师,或者是想要将现有的Flink任务迁移到YARN上运行。用户可能对YARNFlink的基本概念有一定了解,但需要具体的部署步骤和配置说明。 接下来,我需要查看用户提供的引用内容。引用[1]提到准备工作,比如Hadoop集群、环境变量和依赖包。引用[2]和[3]讨论了Session-Cluster模式,包括如何启动yarn-session和提交任务。引用[4]提到了Application模式,使用run-application命令。引用[5]则涉及Hadoop依赖包的处理,需要用户自己下载并放置到lib目录下。 用户的问题是如何在YARN上部署Flink,所以需要覆盖两种主要的部署模式:Session-Cluster和Application Mode。同时,必须确保每个步骤都正确,特别是关于依赖项和配置的部分。可能需要注意的常见问题包括依赖包缺失、Hadoop配置不正确,或者资源分配的问题。 首先,我应该列出部署前的准备工作,如安装Hadoop、配置环境变量、处理Hadoop依赖。然后分别讲解两种部署模式的具体步骤,包括启动集群和提交任务。可能还需要给出示例命令,这样用户可以直接复制使用。此外,需要注意不同模式下资源管理的区别,比如Session-Cluster是常驻的,而Application Mode是任务级别的。 在引用内容中,引用[5]提到需要用户自行下载Hadoop依赖包,并放到Flink的lib目录下。这一点很重要,否则可能会遇到类找不到的错误。需要详细说明这一步,包括下载地址的位置,可能用户需要访问提供的链接或文档来获取正确的依赖包。 另外,提交任务的命令有所不同,Session-Cluster使用flink run,而Application Mode使用flink run-application,并且需要指定Dyarn.provided.lib.dirs参数,引用HDFS上的Flink分发目录。这部分需要明确说明,避免用户混淆。 可能用户还会遇到资源不足的问题,所以在步骤中可以提醒调整资源参数,比如内存和slot数量。同时,需要检查YARN集群的状态,确保Hadoop服务正常运行,否则部署会失败。 最后,生成相关问题的时候,可以考虑用户可能进一步想知道如何优化部署、处理依赖冲突,或者监控Flink任务在YARN上的运行情况。这些问题有助于用户深入学习和解决问题。 现在需要将以上思路整理成一个结构化的回答,分步骤说明,确保每个部分都引用正确的来源,并在末尾添加相关问题。同时,要保持语言简洁,使用中文,符合用户的要求。</think>### Flink on YARN 部署教程 #### 一、部署前准备 1. **Hadoop集群环境** 确保已部署Hadoop集群(版本需与Flink兼容),并启动YARN服务。可通过`jps`命令检查`ResourceManager`和`NodeManager`是否正常运行[^2]。 2. **Flink环境配置** - 下载与Hadoop兼容的Flink版本,并解压到指定目录。 - 配置环境变量: ```bash export HADOOP_CLASSPATH=`hadoop classpath` # 确保Hadoop依赖正确加载[^5] ``` 3. **Hadoop依赖包处理** - 从Flink官网提供的地址下载与Hadoop版本对应的依赖包(如`flink-shaded-hadoop-3-uber.jar`)[^5]。 - 将依赖包复制到Flink的`lib`目录下,否则无法访问HDFS或YARN资源。 --- #### 二、两种部署模式详解 ##### 1. **Session-Cluster模式(常驻集群)** - **特点**:预先分配固定资源,任务共享集群,适合短时高频任务。 - **启动集群**: ```bash ./bin/yarn-session.sh -n 2 -s 2 -jm 1024 -tm 2048 -nm myFlinkSession ``` - `-n`:TaskManager数量 - `-s`:每个TaskManager的Slots数量 - `-nm`:YARN Application名称 - **提交任务**: ```bash flink run examples/streaming/TopSpeedWindowing.jar # 使用已启动的Session集群[^3] ``` ##### 2. **Application Mode(按需集群)** - **特点**:每个任务独立集群,资源按需分配,避免资源竞争[^4]。 - **提交任务**: ```bash ./bin/flink run-application -t yarn-application \ -Dyarn.provided.lib.dirs="hdfs:///flink/libs" \ hdfs:///jars/my-flink-job.jar ``` - `-Dyarn.provided.lib.dirs`:指定HDFS上的Flink依赖目录(需提前上传)[^4]。 --- #### 三、关键注意事项 1. **依赖包冲突** 若出现Hadoop类冲突,检查`lib`目录中是否仅保留**一个**Hadoop依赖包[^5]。 2. **资源参数调整** - 根据集群资源调整`-jm`(JobManager内存)、`-tm`(TaskManager内存)参数。 - 资源不足会导致YARN任务提交失败。 3. **日志查看** 任务日志可通过YARN Web UI(`http://<ResourceManager>:8088`)或`yarn logs -applicationId <appId>`查看。 ---
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值