redis bgsave失败,因为fork无法分配内存 [英] redis bgsave failed because fork Cannot allocate memory

查看:274
本文介绍了redis bgsave失败,因为fork无法分配内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部: 这是我的服务器内存信息,带有"free -m"

all: here is my server memory info with 'free -m'

              total       used       free     shared    buffers     cached
 Mem:         64433       49259      15174          0          3         31
 -/+ buffers/cache:      49224      15209
 Swap:         8197        184       8012

我的redis服务器已使用46G内存,几乎有15G可用空间

my redis-server has used 46G memory, there is almost 15G memory left free

据我所知,fork是写时复制的,当有15G可用内存时,它应该不会失败,这足以分配必要的内核结构.

As my knowledge,fork is copy on write, it should not failed when there has 15G free memory,which is enough to malloc necessary kernel structures .

此外,当redis服务器使用42G内存时,bgsave可以,而fork也可以.

besides, when redis-server used 42G memory, bgsave is ok and fork is ok too.

是否可以调整任何vm参数以使fork成功返回?

Is there any vm parameter I can tune to make fork return success ?

推荐答案

来自 proc(5)手册页:

/proc/sys/vm/overcommit_memory

/proc/sys/vm/overcommit_memory

此文件包含内核虚拟内存记帐模式.值是:

This file contains the kernel virtual memory accounting mode. Values are:

0:启发式过量使用(这是默认设置)

0: heuristic overcommit (this is the default)

1:总是过量使用,从不检查

1: always overcommit, never check

2:始终检查,永不过量使用

2: always check, never overcommit

在模式0下,不检查设置为MAP_NORESERVE的mmap(2)的调用,并且默认检查非常弱,导致存在使进程"OOM终止"的风险.在Linux 2.4下 任何非零值都表示模式1.在模式2(自Linux 2.6起可用)中,系统上的总虚拟地址空间被限制为(SS + RAM *(r/100)),其中SS为大小 交换空间的大小,RAM是物理内存的大小,r是文件/proc/sys/vm/overcommit_ratio的内容.

In mode 0, calls of mmap(2) with MAP_NORESERVE set are not checked, and the default check is very weak, leading to the risk of getting a process "OOM-killed". Under Linux 2.4 any non-zero value implies mode 1. In mode 2 (available since Linux 2.6), the total virtual address space on the system is limited to (SS + RAM*(r/100)), where SS is the size of the swap space, and RAM is the size of the physical memory, and r is the contents of the file /proc/sys/vm/overcommit_ratio.

这篇关于redis bgsave失败,因为fork无法分配内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆