redis常见环境错误及解决(持续更新)

451 阅读1分钟

常见问题

一、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.

image.png

分析原因:

因为强制把redis快照关闭了导致不能持久化的问题,在网上查了一些相关解决方案,通过stop-writes-on-bgsave-error值设置为no即可避免这种问题。

解决问题

方法一

按照网上的方式,更改系统配置文件/etc/sysctl.conf,但是改了之后没有效果

1、更改配置文件sysctl.conf,添加vm.overcommit_memory=1,如下 vim /etc/sysctl.conf

image.png

2、文件生效 sudo sysctl -p /etc/sysctl.conf

方法二

1、在本redis实例修改 config set stop-writes-on-bgsave-error no。或者配置文件中定位到stop-writes-on-bgsave-error,将值改为no,结果有效,如下所示 image.png