遇到的问题:

(error) 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正在保存快照,无法对其数据进行任何更新,包括flushall等指令

解决方案:
连接redis后运行 config set stop-writes-on-bgsave-error no 命令

关闭配置项stop-writes-on-bgsave-error解决该问题。

另外一个问题:
报错原因:READONLY You can’t write against a read only slave.
进入redis.conf配置文件,修改配置文件的slave-read-only为no,
那么从节点也就可以进行写的操作了,代码不会报错

命令:

config set slave-read-only no

愿你出走半生,归来仍是少年