诊断 RDB/AOF 错误状态、fork 时间及 MISCONF 的原因
Redis持久化命令
INFO persistence
# Critical fields: rdb_last_bgsave_status, aof_last_bgrewrite_status, aof_last_write_status, rdb_changes_since_last_save, aof_delayed_fsync
INFO stats
# latest_fork_usec: duration of the last fork (microseconds), total_forks
CONFIG GET stop-writes-on-bgsave-error
CONFIG GET dir
CONFIG GET appendfsync作用
显示上次 RDB 快照和 AOF 重写/写入是否成功、自上次保存以来变更的 key 数量、延迟 fsync 次数以及 fork 耗时。
适用场景
应用收到 'MISCONF Redis is configured to save RDB snapshots, but it's currently unable to persist to disk'、BGSAVE/BGREWRITEAOF 失败,或出现与 fork 相关的延迟时。
注意
在 stop-writes-on-bgsave-error yes(默认)下,BGSAVE 失败后所有写入都会被拒绝。将其设为 'no' 来消除错误会掩盖数据丢失风险;先修复原因:磁盘已满、对 dir 无写权限,或 fork 无法获得内存(vm.overcommit_memory=0)。在大数据集上 fork 时间可达数百毫秒,其间 Redis 不响应。