redis:修复将快照保存到数据库时出现内存错误

redis:修复将快照保存到数据库时出现内存错误

我在 redis 日志中看到以下错误:

[17541] 8 月 10 日 16:13:21.055 * 900 秒内发生 1 次更改。正在保存...

[17541] 8 月 10 日 16:13:21.055 # 无法在后台保存:fork:无法分配内存 [17541]

错误信息如下:

> Error running script (call to
> f_1477e1798ff8d1bae3066a94781114c056f9ef08): @user_script:8:
> @user_script: 8: -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.

这看起来很奇怪,因为 dump.rdb 文件似乎相当小,大约 90Mb。而且我还尝试在同一个文件夹中创建另一个文件,并成功做到了(因此磁盘空间不是问题)。权限对我来说看起来不错:

ubuntu@ip-172-31-39-198:/var/lib/redis$ ls -hla
total 89M
drwxr-xr-x  2 redis redis 4.0K Aug 10 16:23 .
drwxr-xr-x 47 root  root  4.0K Aug 10 15:18 ..
-rw-rw----  1 redis redis  89M Aug 10 15:19 dump.rdb

经过谷歌搜索后,我发现这是一个解决方案: echo 1 > /proc/sys/vm/overcommit_memory sysctl vm.overcommit_memory=1

这对我来说毫无意义,因为我希望通过 redis 配置解决这个问题...你能建议该怎么做吗?

答案1

就像声明的那样这里,你可能想要sysctl vm.overcommit_memory=1作为su,也许编辑/etc/sysctl.conf以添加vm.overcommit_memory=1

相关内容