Apache flink Flink删除旧的检查点文件
我们使用文件系统作为检查点状态后端。以下是我们的设置:Apache flink Flink删除旧的检查点文件,apache-flink,Apache Flink,我们使用文件系统作为检查点状态后端。以下是我们的设置: StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setStreamTimeCharacteristic(timeCharacteristic); env.getConfig().setAutoWatermarkInterval(Time.seconds(30).toMilliseconds()); env.e
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setStreamTimeCharacteristic(timeCharacteristic);
env.getConfig().setAutoWatermarkInterval(Time.seconds(30).toMilliseconds());
env.enableCheckpointing(Time.seconds(30).toMilliseconds());
CheckpointConfig checkpointConfig = env.getCheckpointConfig();
checkpointConfig.setCheckpointingMode(CheckpointingMode.EXACTLY_ONCE);
env.setStateBackend(new FsStateBackend(props.getProperty("backendstate.path")));
这在开发过程中效果很好,但一旦部署到生产环境中,我们就发现检查点文件会很快占用磁盘空间。我对其中一个检查点目录做了一个ls,并找到了它
chk-10 chk-104 chk-13 chk-18 chk-23 chk-28 chk-32 chk-37 chk-41 chk-46 chk-50 chk-55 chk-6 chk-64 chk-69 chk-73 chk-78 chk-82 chk-87 chk-91 chk-96 chk-100 ... hundreds of them
我想知道是否有办法删除旧的chk-x文件,或者我们必须手动删除它们 你可以试试这个
CheckpointConfig config = env.getCheckpointConfig();
config.enableExternalizedCheckpoints(ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION);
ExternalizedCheckpointCleanup模式配置取消作业时外部化检查点的情况:
外部化检查点清理。取消时保留检查点:取消作业时保留外部化检查点。请注意,在这种情况下,取消后必须手动清除检查点状态
外部化检查点清理。取消时删除检查点:取消作业时删除外部化检查点。只有作业失败时,检查点状态才可用。在部署期间,将“conf/flink-conf.yaml”文件中的以下属性设置为要保留的最大检查点数:
state.checkpoints.num-retained
理想情况下,它应该大于1,因为如果最后一个检查点损坏,它有助于恢复作业
有关详细信息,请查看:Flink作业管理器必须能够访问存储文件的节点,才能将其删除。 在同一台大型计算机中运行所有组件,或者使用DFS作为检查点存储