Flink_YARN 上资源申请流程
Base on Flink 1.10.1
Flink 托管给Yarn 是一个非常常用的形式,下面我们通过官网给出的流程图,了解下 Flink On Yarn 的任务执行流程。
前提 :
首先,我们如果能让我们的任务在Yarn 上托管执行,我们是需要设置一些环境变量 :
The YARN client needs to access the Hadoop configuration to connect to the YARN resource manager and HDFS. It determines the Hadoop configuration using the following strategy:
- Test if
YARN_CONF_DIR
,HADOOP_CONF_DIR
orHADOOP_CONF_PATH
are set (in that order). If one of these variables is set, it is used to read the configuration. - If the above strategy fails (this should not be the case in a correct YARN setup), the client is using the
HADOOP_HOME
environment variable. If it is set, the client tries to access$HADOOP_HOME/etc/hadoop
(Hadoop 2) and$HADOOP_HOME/conf
(Hadoop 1).
运行流程
结合官网给出的流程图
https://ci.apache.org/projects/flink/flink-docs-release-1.10/ops/deployment/yarn_setup.html
我们来讲解下 Flink ON YARN 的执行流程
1.上传依赖和Config文件
2.请求资源,申请AppMaster容器
3.分配(allocate) AppMaster 容器
容器内部:
启动的Flink JobManager 和 Yarn App Master 在同一个 Container 中
两种模式:
Yarn 上分为 Yarn Session 与 Yarn Single Job 两种方式
其中Yarn Session 相当于 JobManger 进行了复用,而Single Job 相当于每个 Job 都去申请 AppMaster 和 JobManager
4.分配Yarn Container , 其中 Flink TaskManager 分配在 Container 中