1- Savepoint概述
- Flink流式计算,提供Checkpoint机制,程序
自动将State进行快速Snapshot
,然后进行Checkpoint保存
。此外,还支持用户可以手动进行Snapshot,保存State数据,称为:SavePoint
保存点。
Savepoint
:保存点,类似于以前玩游戏的时候,遇到难关/遇到boss,赶紧手动存个档,然
后接着玩,如果失败了,赶紧从上次的存档中恢复,然后接着玩。
- Checkpoint 与Savepoint区别:
2- Savepoint演示
案例演示说明:运行前面Checkpoint程序(配置自动重启策略),将其运行在YARN集群上,采用WEB UI界面方式部署运行(flink on yarn Session会话模式)。
# 启动yarn session
/export/server/flink/bin/yarn-session.sh -jm 1024 -tm 1024 -s 2 -d
# 运行job-会自动执行Checkpoint
/export/server/flink/bin/flink run -d \
--class cn.itcast.flink.checkpoint.StreamCheckpointDemo \
/root/ckpt.jar hdfs://node1.itcast.cn:8020/flink-checkpoint/checkpoint
# 手动创建savepoint--相当于手动做了一次Checkpoint
/export/server/flink/bin/flink savepoint 461e4d99b207e435022a6bd2f7b2e5bd \
hdfs://node1.itcast.cn:8020/flink-checkpoint/savepoint/
# 停止job
/export/server/flink/bin/flink cancel 461e4d99b207e435022a6bd2f7b2e5bd
# 重新启动job,手动加载savepoint数据
/export/server/flink/bin/flink run -d \ -s hdfs://node1.itcast.cn:8020/flink-checkpoint/savepoint/savepoint-461e4d-fb937e8062f7 \
--class cn.itcast.flink.checkpoint.StreamCheckpointDemo \
/root/ckpt.jar hdfs://node1.itcast.cn:8020/flink-checkpoint/checkpoint
# 停止yarn session
yarn application -kill application_1598434063229_0001