【Redis】报错:Redis is configured to save RDB snapshots, but it is currently not able to persist on disk
今天Redis服务器在连接redis数据库时突然报错:
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. 命令行方式 (重启redis失效)
命令行修改方式示例:
127.0.0.1:6379> config set stop-writes-on-bgsave-error no
2. 修改配置文件(重启redis不失效)
修改redis.conf文件:vi打开redis-server配置的redis.conf文件,然后使用快捷匹配模式:/stop-writes-on-bgsave-error定位到stop-writes-on-bgsave-error字符串所在位置,接着把后面的yes设置为no即可。
配置文件说明:
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.
默认情况下,如果启用了RDB快照,Redis将停止接受写入 (至少一个保存点)并且最近一次后台保存失败。 这将使用户意识到(以一种艰难的方式)数据没有正确地持久存储在磁盘上,否则很可能没有人会注意到 灾难会发生。 如果后台保存过程将再次开始工作,Redis将 自动允许再次写入。 但是,如果您已经设置了对Redis服务器的适当监控 和持久性,您可能希望禁用这个特性,以便Redis将 即使磁盘出现问题也能照常工作, 权限等等。
本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://www.net2asp.com/6bc34eaf14.html
