redis报Can't save in background: fork: Cannot allocate memory错误

开发那边传过来错误:

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, 表示内核允许分配超过所有物理内存和交换空间总和的内存

你可能感兴趣的:(Linux,redis)