解决redis连接报错:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to...

 出现的错误信息如下:

MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on 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快照被强制关闭了导致不能持久化的问题,通过stop-writes-on-bgsave-error值设置为no即可避免这种问题

两个解决方法:

一种是通过redis命令行修改,另一种是直接修改redis.conf配置文件.

1.命令行修改:输入命令 config set stop-writes-on-bgsave-error no,如下

然后重启redis-server。

2.修改redis.conf文件:

vi打开redis-server配置的redis.conf文件,然后使用快捷匹配模式:/stop-writes-on-bgsave-error定位到stop-writes-on-bgsave-error字符串,接着把后面的yes改为no就可以了。

根本解决
在后面的使用中发现这两个方法只是暂时解决了报错的问题,虽然能继续写数据,但是会导致数据不能保存数据到dump.rdb中,我们需要在日志文件中查看具体错误原因。

但是redis在默认情况下,是不会生成日志文件的,所以需要配置,配置如下:
1、打开配置文件redis.conf,使用快捷匹配模式/logfile

2、将自定义的路径写到logfile后面的引号内,例如:logfile “/myredis/redis.log”

3、手动创建/myredis/文件夹,日志文件不用创建,重启redis会自动生成。

配置完成后,重启redis后可以看到日志文件redis.log自动生成了,如下:

我出现的是用户权限问题,当前用户不能操作dump.rdb。使用root用户或者使用root用户进行权限授权就可以解决这个问题。

posted @ 2022-09-15 16:45  小旭的blog  阅读(10269)  评论(0编辑  收藏  举报