Redis|报错 MISCONF Redis is configured to save RDB snapshots 问题修复方法

问题现象

使用 DataGrip 使用 SSH 远程连接 Redis 时报错如下:

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.

但是直接在服务器上使用 redis-cli 命令或在开发机用 Python SDK 通过 SSH 远程连接均正常。

问题原因

Redis 配置为保存 RDB 快照,但目前无法再磁盘上持久化。可能修改数据集的命令将被禁用,因为此实例配置在 RDB 快照失败时报告报错。

这说明当前 RDB 快照写入是有问题的,我们需要解决 RDB 快照的问题。如果这个问题是在执行了第一个 Redis 写入命令后出现,那么说明 Redis 的 RDB 配置完全异常。

对于这种情况,我们首先考虑的应该是,如何解决 RDB 快照写入问题,令 Redis 可以正常持久化,此乃上策。只有实在无法解决 RDB 快照写入问题,再考虑关闭 Redis 的 RDB 快照写入失败的报错,让 Redis 在无法持久化数据的情况下运行,此乃无可奈何之下策。

上策:修复 RDB 快照写出问题

可能原因 1:启动 Redis 服务的用户权限不够

如果启动 Redis 服务的用户权限不够,则将导致无法在 Redis 文件夹中写出 dump.rdb 文件。

建议检查启动 Redis 进程的用户是否有 Redis 目录的权限,如果没有则切换用户或赋予权限。

下策:屏蔽 RDB 写入失败报错

通过将 stop-writes-on-bgsave-error 配置置为 no,也可以让 RDB 写入失败不再报错。需要注意的是,这样的修改会令 Redis 实际不再进行持久化,只是不再显示问题,而非解决了问题!!!

这个配置项的说明信息如下:

# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# This will make the user aware (in a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.
#
# If the background saving process will start working again Redis will
# automatically allow writes again.
#
# 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.
stop-writes-on-bgsave-error yes
增加临时配置(重启 Redis 失效)

启动 Redis 客户端(redis-cli),执行如下命令:

config set stop-writes-on-bgsave-error no
修改永久配置(重启 Redis 不失效)

修改 redis.conf 文件中的 stop-writes-on-bgsave-error 配置项,将那一行改为:

stop-writes-on-bgsave-error no
  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

长行

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值