用redis-cli 创建 set时,提示无法修改数据

错误信息如下


(error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

日志信息如下


3930:M 13 Dec 22:48:20.115 # Background saving error
3930:M 13 Dec 22:48:26.025 * 1 changes in 900 seconds. Saving...
3930:M 13 Dec 22:48:26.025 * Background saving started by pid 11584
11584:C 13 Dec 22:48:26.025 # Failed opening the RDB file root (in server root dir /etc/cron.d) for saving: Permission denied

可以发现因为权限问题 ,无法保存快照。

重启下redis 查看一下redis启动时的日志


WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

可以发现低内存可能导致后台保存快照失败

解决方案也在上面了 即


sysctl vm.overcommit_memory=1