【Flink使⽤注意】Flinkcheckpoint清除策略使⽤指南
⽂章⽬录男人虚
Flink checkpoint使⽤Stop命令停⽌任务后会⾃动删除checkpoint ⽬录?
Flink Checkpoint ⽬录的清除策略
深圳有什么山应⽤代码
CheckpointConfig checkPointConfig = CheckpointConfig();
checkPointConfig.tCheckpointingMode(CheckpointingMode.EXACTLY_ONCE);
checkPointConfig.tCheckpointTimeout(1*60*1000);
分类标记
checkPointConfig.tMinPauBetweenCheckpoints((1*30*1000));
checkPointConfig.tMaxConcurrentCheckpoints(1);
checkPointConfig.tTolerableCheckpointFailureNumber(3);
checkPointConfig
.enableExternalizedCheckpoints(ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION);
Flink源码
org.apache.flink.vironment.CheckpointConfig.ExternalizedCheckpointCleanup有两种策略:
/**
* Delete externalized checkpoints on job cancellation.
*爱护造句
* <p>All checkpoint state will be deleted when you cancel the owning
* job, both the meta data and actual program state. Therefore, you
* cannot resume from externalized checkpoints after the job has been
* cancelled.
*
* <p>Note that checkpoint state is always kept if the job terminates
* with state {@link JobStatus#FAILED}.
*/
DELETE_ON_CANCELLATION(true),
/**
* Retain externalized checkpoints on job cancellation.
*
* <p>All checkpoint state is kept when you cancel the owning job. You
来去的四字词语* have to manually delete both the checkpoint meta data and actual
* program state after cancelling the job.
*
赞美造句* <p>Note that checkpoint state is always kept if the job terminates
* with state {@link JobStatus#FAILED}.
求婚大作战日版*/
RETAIN_ON_CANCELLATION(fal);
DELETE_ON_CANCELLATION:仅当作业失败时,作业的 Checkpoint 才会被保留⽤于任务恢复。当作业取消时,Checkpoint 状态信息会被删除,因此取消任务后,不能从 Checkpoint 位置进⾏恢复任务。
湖南三本
RETAIN_ON_CANCELLATION:当作业⼿动取消时,将会保留作业的 Checkpoint 状态信息。注意,这种情况下,需要⼿动清除该作业保留的 Checkpoint 状态信息,否则这些状态信息将永远保留在外部的持久化存储中。
需要注意
即使使⽤了RETAIN_ON_CANCELLATION命令,当使⽤flink stop命令来停⽌任务时也会删除Checkpoint ⽬录,这是因为这个机制是适⽤于使⽤cancel命令取消的任务的。
以下是⽹友做的测试:
启动后等待若⼲检查点之后做如下操作⽂件系统上的检查点是否保留说明
WEB UI 点击 Cancel ⽅式取消任务 保留 合理,因为设置了 RETAIN_ON_CANCELLATION。通过命令⽣成保存点:flink savepoint ${jobId} ${savepointDir} 保留 OK
通过命令取消任务:flink cancel ${jobId} 保留 OK
通过命令取消任务并⽣成保存点:flink cancel -s ${savepointDir} ${jobId} 保留 OK
通过命令停⽌任务(基于默认保存点⽬录):flink stop ${jobId} 不保留 注意别被特点坑
通过命令停⽌任务并⽣成保存点:flink stop -p ${savepointDir} ${jobId} 不保留 注意别被特点坑