如何修复错误“(错误)MISCONF Redis 配置为保存 RDB 快照”?

上次更新 2024 年 3 月 22 日

问题

每次尝试写入一个新密钥时,Redis OSS 的默认配置都会导致此错误。如何解决此问题?

127.0.0.1:6379> sadd mykey:name john1
(error) MISCONF Redis is configured to save RDB snapshots, but it's currently unable to persist to disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

回答

在将数据持久化到磁盘时会出现问题。虽然这些错误必须在系统级别进行故障排除,但实现写入操作并使其发生的解决方法是在配置或运行时设置以下配置以允许写入。

config set stop-writes-on-bgsave-error no

参考

在 Redis 配置文件 中查看 Redis 服务器版本的文档,其中可以找到说明

# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.