Flink以Standalone模式运行时,可能会发生jobmanager(以下简称jm)或taskmanager(以下简称tm)异常退出的情况,我们可以使用Linux自带的Systemd方式管理jm以及tm的启停,并在jm或tm出现故障时,及时将jm以及tm拉起来。

Flink在1.11版本后,从发行版中移除了对Hadoop的依赖包,如果需要使用Hadoop的一些特性,有两种解决方案:

】以下假设java、flink、hadoop都安装在/opt目录下,并且都建立了软连接:

1.设置HADOOP_CLASSPATH环境变量(推荐方案

在安装了Flink的所有节点上,在/etc/profile中进行如下设置:

# Hadoop Envexport HADOOP_HOME=/opt/hadoopexport PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbinexport HADOOP_CLASSPATH=`hadoop classpath`

然后通过以下命令使环境变量生效

sudo source /etc/profile

2.下载flink-shaded-hadoop-2-uber对应的jar包,并拷贝到Flink安装路径的lib目录下

下载地址:https://flink.apache.org/downloads.html#additional-components

由于以systemd方式启动时,系统设置的环境变量,在.service文件中是不能使用的,所以需要在.service文件中单独显式设置环境变量

1./usr/lib/systemd/system/flink-jobmanager.service

[Unit]
Description=Flink Job Manager
After=syslog.target network.target remote-fs.target nss-lookup.target network-online.target
Requires=network-online.target [Service]
User=teld
Group=teld
Type=forking
Environment=PATH=/opt/java/bin:/opt/flink/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Environment=JAVA_HOME=/opt/java
Environment=FLINK_HOME=/opt/flink
Environment=HADOOP_CLASSPATH=/opt/hadoop/etc/hadoop:/opt/hadoop/share/hadoop/common/lib/*:/opt/hadoop/share/hadoop/common/*:/opt/hadoop/
share/hadoop/hdfs:/opt/hadoop/share/hadoop/hdfs/lib/*:/opt/hadoop/share/hadoop/hdfs/*:/opt/hadoop/share/hadoop/yarn/lib/*:/opt/hadoop/sh
are/hadoop/yarn/*:/opt/hadoop/share/hadoop/mapreduce/lib/*:/opt/hadoop/share/hadoop/mapreduce/*:/opt/hadoop/contrib/capacity-scheduler/*
.jar
ExecStart=/opt/flink/bin/jobmanager.sh start
ExecStop=/opt/flink/bin/jobmanager.sh stop Restart=on-failure [Install]
WantedBy=multi-user.target

】HADOOP_CLASSPATH对应的值,是通过执行以下命令获得到的:

hadoop classpath

2./usr/lib/systemd/system/flink-taskmanager.service

[Unit]
Description=Flink Task Manager
After=syslog.target network.target remote-fs.target nss-lookup.target network-online.target
Requires=network-online.target [Service]
User=teld
Group=teld
Type=forking
Environment=PATH=/opt/java/bin:/opt/flink/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Environment=JAVA_HOME=/opt/java
Environment=FLINK_HOME=/opt/flink
Environment=HADOOP_CLASSPATH=/opt/hadoop/etc/hadoop:/opt/hadoop/share/hadoop/common/lib/*:/opt/hadoop/share/hadoop/common/*:/opt/hadoop/
share/hadoop/hdfs:/opt/hadoop/share/hadoop/hdfs/lib/*:/opt/hadoop/share/hadoop/hdfs/*:/opt/hadoop/share/hadoop/yarn/lib/*:/opt/hadoop/sh
are/hadoop/yarn/*:/opt/hadoop/share/hadoop/mapreduce/lib/*:/opt/hadoop/share/hadoop/mapreduce/*:/opt/hadoop/contrib/capacity-scheduler/*
.jar
ExecStart=/opt/flink/bin/taskmanager.sh start
ExecStop=/opt/flink/bin/taskmanager.sh stop Restart=on-failure [Install]
WantedBy=multi-user.target

】HADOOP_CLASSPATH对应的值,是通过执行以下命令获得到的:

hadoop classpath

通过sudo systemctl daemon-reload命令来加载上面针对jm以及tm的配置后,就可以使用Systemd的方式来管理jm以及tm了,并且能够在jm以及tm异常退出时,及时将它们拉起来:

sudo systemctl start flink-jobmanager.service

sudo systemctl stop flink-jobmanager.service
sudo systemctl status flink-jobmanager.service
sudo systemctl start flink-taskmanager.service

sudo systemctl stop flink-taskmanager.service
sudo systemctl status flink-jobmanager.service

遇到的坑:

1.如果Flink设置了启用Checkpoint,但是没有设置HADOOP_CLASSPATH环境变量,则提交job的时候,会报如下异常:

Caused by: org.apache.flink.util.FlinkRuntimeException: Failed to create checkpoint storage at checkpoint coordinator side.
at org.apache.flink.runtime.checkpoint.CheckpointCoordinator.<init>(CheckpointCoordinator.java:304)
at org.apache.flink.runtime.checkpoint.CheckpointCoordinator.<init>(CheckpointCoordinator.java:223)
at org.apache.flink.runtime.executiongraph.ExecutionGraph.enableCheckpointing(ExecutionGraph.java:483)
at org.apache.flink.runtime.executiongraph.ExecutionGraphBuilder.buildGraph(ExecutionGraphBuilder.java:338)
at org.apache.flink.runtime.scheduler.SchedulerBase.createExecutionGraph(SchedulerBase.java:269)
at org.apache.flink.runtime.scheduler.SchedulerBase.createAndRestoreExecutionGraph(SchedulerBase.java:242)
at org.apache.flink.runtime.scheduler.SchedulerBase.<init>(SchedulerBase.java:229)
at org.apache.flink.runtime.scheduler.DefaultScheduler.<init>(DefaultScheduler.java:119)
at org.apache.flink.runtime.scheduler.DefaultSchedulerFactory.createInstance(DefaultSchedulerFactory.java:103)
at org.apache.flink.runtime.jobmaster.JobMaster.createScheduler(JobMaster.java:284)
at org.apache.flink.runtime.jobmaster.JobMaster.<init>(JobMaster.java:272)
at org.apache.flink.runtime.jobmaster.factories.DefaultJobMasterServiceFactory.createJobMasterService(DefaultJobMasterServiceFac
tory.java:98)
at org.apache.flink.runtime.jobmaster.factories.DefaultJobMasterServiceFactory.createJobMasterService(DefaultJobMasterServiceFac
tory.java:40)
at org.apache.flink.runtime.jobmaster.JobManagerRunnerImpl.<init>(JobManagerRunnerImpl.java:140)
at org.apache.flink.runtime.dispatcher.DefaultJobManagerRunnerFactory.createJobManagerRunner(DefaultJobManagerRunnerFactory.java
:84)
at org.apache.flink.runtime.dispatcher.Dispatcher.lambda$createJobManagerRunner$6(Dispatcher.java:388)
... 7 more
Caused by: org.apache.flink.core.fs.UnsupportedFileSystemSchemeException: Could not find a file system implementation for scheme 'hdfs'.
The scheme is not directly supported by Flink and no Hadoop file system to support this scheme could be loaded. For a full list of supp

2.在为flink-jobmanager.service以及flink-taskmanager.service中的HADOOP_CLASSPATH环境变量赋值时,尝试使用过反引号,期望将反引号内的Linux命令执行结果赋予变量,但实际上并不会执行反引号中的内容:

Environment=HADOOP_CLASSPATH=`/opt/hadoop/bin/hadoop classpath`

最后只得将直接执行hadoop classpath获得的结果,粘贴到.service文件中

Environment=HADOOP_CLASSPATH=/opt/hadoop/etc/hadoop:/opt/hadoop/share/hadoop/common/lib/*:/opt/hadoop/share/hadoop/common/*:/opt/hadoop/
share/hadoop/hdfs:/opt/hadoop/share/hadoop/hdfs/lib/*:/opt/hadoop/share/hadoop/hdfs/*:/opt/hadoop/share/hadoop/yarn/lib/*:/opt/hadoop/sh
are/hadoop/yarn/*:/opt/hadoop/share/hadoop/mapreduce/lib/*:/opt/hadoop/share/hadoop/mapreduce/*:/opt/hadoop/contrib/capacity-scheduler/*
.jar

Standalone模式下,通过Systemd管理Flink1.11.1的启停及异常退出的更多相关文章

  1. sql服务器第5级事务日志管理的阶梯:完全恢复模式下的日志管理

    sql服务器第5级事务日志管理的阶梯:完全恢复模式下的日志管理 原文链接http://www.sqlservercentral.com/articles/Stairway+Series/73785/ ...

  2. 关于spark standalone模式下的executor问题

    1.spark standalone模式下,worker与executor是一一对应的. 2.如果想要多个worker,那么需要修改spark-env的SPARK_WORKER_INSTANCES为2 ...

  3. VLAN 模式下的 OpenStack 管理 vSphere 集群方案

    本文不合适转载,只用于自我学习. 关于为什么要用OpenStack 管理 vSphere 集群,原因可以有很多,特别是一些传统企业,VMware 的使用还是很普遍的,用 OpenStack 纳管至少会 ...

  4. 【Spark】Spark-shell案例——standAlone模式下读取HDFS上存放的文件

    目录 可以先用local模式读取一下 步骤 一.先将做测试的数据上传到HDFS 二.开发scala代码 standAlone模式查看HDFS上的文件 步骤 一.退出local模式,重新进入Spark- ...

  5. weblogic管理3 - 生产模式下免密码管理配置

    admin server免密码配置 >1.  生产模式中admin root目录下是否存在security/boot.properties文件 [weblogic@11g AdminServer ...

  6. windows游戏编程X86 32位保护模式下的内存管理概述(二)

    本系列文章由jadeshu编写,转载请注明出处.http://blog.csdn.net/jadeshu/article/details/22448323 作者:jadeshu   邮箱: jades ...

  7. SQL Server Reporting Services本机模式下的权限管理

    SQL Server Reporting Services在安装配置后,缺省只给BUILTIN\Administrators用户组(实际上只有本机的Administrator用户)提供管理权限.所以所 ...

  8. 在standalone模式下运行yarn 0.9.0对HDFS上的数据进行计算

    1.通读http://spark.incubator.apache.org/docs/latest/spark-standalone.html 2.在每台机器上将spark安装到/opt/spark ...

  9. Spark在StandAlone模式下提交任务,spark.rpc.message.maxSize太小而出错

    1.错误信息org.apache.spark.SparkException: Job aborted due to stage failure:Serialized task 32:5 was 172 ...

  10. windows游戏编程X86 32位保护模式下的内存管理概述(一)

    本系列文章由jadeshu编写,转载请注明出处.http://blog.csdn.net/jadeshu/article/details/22445945 作者:jadeshu   邮箱: jades ...

随机推荐

  1. Git的.gitignore文件配置

    .gitignore是Git工具的配置文件,用于屏蔽某些文件上传到线上. 创建.gitignore 在window系统中,不允许新建文件名以"."开头的文件,所以通过git bas ...

  2. javascript特殊运算符

    in运算符                 in运算符要求其左边的运算数是一个字符串,或可以被转换为字符串,右边的运算数十一个对象或数组.如果该 运算符左边的值是右边对象的一个属性名,则返回true, ...

  3. [数据结构与算法]队列Queue 的多种实现

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  4. esayui-datagrid的使用

    第一步:在页面上引入easyui的jQuery链接 <script src="../../Scripts/easyUI/jquery-1.7.2.min.js" type=& ...

  5. 获得项目的绝对地址 getRequestURI,getRequestURL的区别

    java获得tomcat项目的绝对地址 String basePath = request.getScheme()+"://"+request.getServerName()+&q ...

  6. stringstream转换CString为string出错

    使用stringstream转换CString为string时,调试时发现是CString赋给stringstream没有问题,stringstram赋给string就不行,倒也不是没有赋成功,只是赋 ...

  7. hdu1686 Oulipo KMP/AC自动机

    The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e ...

  8. 01:MFC应用程序编程

    一 MFC的发展 VC 1.0->VC 5.0->VC 6.0->VC2008 SP1)->VS2010 二 MFC基础 1 MFC 微软基础类库 采用类的方式,将Win32 ...

  9. github git 无法读取远程仓库或无权限

    解决方法:重新设置ssh密钥 ssh-keygen -t rsa -C "http://github.com"//输入命令后按提示输入id_rsa.pub的存储地址 和密钥密码 地 ...

  10. Django(图书管理系统1)

    day63 内容回顾     1. 单表的增删改查         1. 删和改             1. GET请求 URL传值                 1. 格式            ...