flink checkpoint 重启_Flink Sql on Zeppelin之Checkpoint应用

1 概述

我们都知道,使用Scala或者Java写代码的时候可以配置Flink Checkpoint:

val env = StreamExecutionEnvironment.getExecutionEnvironment  .enableCheckpointing(5 * 60 * 1000)val checkpointConfig = env.getCheckpointConfigcheckpointConfig.setMinPauseBetweenCheckpoints(2 * 60 * 1000)checkpointConfig.setCheckpointTimeout(3 * 60 * 1000)checkpointConfig.enableExternalizedCheckpoints(ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION)

但这对于其他并不善于写代码的同事来说是很麻烦的事情,难以维护。我们使用Flink Sql + Zeppelin不就是想尽可能地干掉代码,使用纯SQL+配置吗?

好在Flink已经支持了Checkpoint相关配置,接下来开始介绍。

# Zeppelin配置Flink Checkpoint

%flink.conf# 开启Checkpoint,指定两次checkpoint开始调度之间的间隔,单位毫秒# 当然,还会受到checkpoint并发数和min-pause影响execution.checkpointing.interval 120000# 开始下次Checkpoint时距离上一次Checkpoint完成后的最小时间间隔,单位毫秒execution.checkpointing.min-pause 60000# 如果某次Checkpoint超过此阈值还没完成,则将进行中的Checkpoint干掉作废,单位毫秒execution.checkpointing.timeout 60000# 当Cancel该job时也保留 Checkpoint,用于作业手动重启# 此模式下我们必须在Cancel后需要手动删除Checkpoint文件。execution.checkpointing.externalized-checkpoint-retention RETAIN_ON_CANCELLATION# 从Checkpoint或Savepoint恢复时使用# execution.savepoint.path hdfs:/flink/flink-checkpoints/a84fccc7d3ff03f0c111bb98e176e1da/chk-1

这样就配置好了Checkpoint。

关于Checkpoint更多详细配置请参考Flink官网:

https://ci.apache.org/projects/flink/flink-docs-release-1.11/ops/config.html

# 从Checkpoint恢复

1. 如果要准备修改作业需要重启,则先在Flink UI中记录下最新的Checkpoint地址:

1679b739aac6ab490c8e4d525f2cf6a4.png

2. 随后在Zeppelin中暂停该任务:

0f1b4033d4254ccd535e42ca63daeca2.png

3. 修改完成后,请务必在%flink.conf中加入以下配置

execution.savepoint.path hdfs:/flink/flink-checkpoints/a84fccc7d3ff03f0c111bb98e176e1da/chk-1

当然,路径换成我们刚才记录的。

4. 重启该Notebook的Flink Interpreter,随后重新运行%flink.conf使得新配置生效。

5. 最后,在Zeppelin重新提交该Flink任务,可观察到该任务从Checkpoint恢复:

5aa3804bda03da12a9d0153be753eb1d.png

# 更多Flink On Zeppelin内容

我个人写的FlinkSql On Zeppelin  博客

https://blog.csdn.net/baichoufei90/article/details/105294787

如果有碰到任何问题,请加入下面这个钉钉群讨论。

b5a3d2f1f6ff6536c13f224821e267f5.png

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值