开发那边传过来错误:
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日志:
29300:M 17 Jan 13:50:38.040 * 1 changes in 900 seconds. Saving...
29300:M 17 Jan 13:50:38.040 # Can't save in background: fork: Cannot allocate memory
free -g看了下内存,果然没有空间了。
所以:
1、设置最大内存从原来的6G变为4G
2、echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf sysctl -p
参数说明:
overcommit_memory=0, 表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。
overcommit_memory=1, 表示内核允许分配所有的物理内存,而不管当前的内存状态如何。
overcommit_memory=2, 表示内核允许分配超过所有物理内存和交换空间总和的内存

本文详细解析了Redis因内存不足导致无法保存RDB快照的问题,通过调整最大内存限制及修改内核参数overcommit_memory来解决,确保Redis在有限资源下稳定运行。
2422

被折叠的 条评论
为什么被折叠?



