前言

之前系统出现过几次hung住的情况,没有oom,也没有其它内存相关的信息,而linux设计就是去尽量吃满内存,然后再回收清理的机制

探讨

目前这个参数还没有找到合适的处理这个预留的参数,一般也没有去调整的

系统是默认根据物理内存进行计算得到一个数值得

sysctl -a|grep min_free_kbytes
vm.min_free_kbytes = 45056

查看内核参数,这个小环境是保留的45M

网上的一些说法

Aerospike 的说法

https://discuss.aerospike.com/t/how-to-tune-the-linux-kernel-for-memory-performance/4195

The standard RedHat recommendation 204 is to keep min_free_kbytes at 1-3% of the total memory on the system, with Aerospike advising to keep at least 1.1GB, even if that is above the official recommended total memory percentage.

On a system with over 37GB of total RAM, you should leave no more than 3% of spare memory to min_free_kbytes in order to avoid the kernel spending too much time unnecessarily reclaiming memory. This would equal anywhere between 1.1GB and 3% of total RAM on such systems.

上面的说法是如果环境内存超过37G的情况下,按3%算就是1.1G,我们一般的环境也超过了40G,那么基本就是建议最少留个1.1G的,100G的可以保留到3G左右

内核参数

vm.min_free_kbytes = 1153434

vm.min_free_kbytes = 3145728

红帽的说法

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/performance_tuning_guide/sect-red_hat_enterprise_linux-performance_tuning_guide-configuration_tools-configuring_system_memory_capacity

Setting min_free_kbytes too low prevents the system from reclaiming memory. This can result in system hangs and OOM-killing multiple processes.

However, setting min_free_kbytes too high (for example, to 5–10% of total system memory) causes the system to enter an out-of-memory state immediately, resulting in the system spending too much time reclaiming memory.

红帽的说法是需要低于总内存的5%

ltp测试里面的参数控制

https://sourceforge.net/p/ltp/mailman/message/29738250/

Setting min_free_kbytes too high will cause system hangs,
especially in i386 arch, using less than 5% of total memory
can avoid it, so choose %5 of free memory or 2% of total memory.
Thanks Shuang pointed out it.
 * Description:
*
* The case is designed to test min_free_kbytes tunable.
*
* The tune is used to control free memory, and system always
* reserve min_free_kbytes memory at least.
*
* Since the tune is not too large or too little, which will
* lead to the system hang, so I choose two cases, and test them
* on all overcommit_memory policy, at the same time, compare
* the current free memory with the tunable value repeatedly. * a) default min_free_kbytes with all overcommit memory policy
* b) 2x default value with all overcommit memory policy
* c) 5% of MemFree or %2 MemTotal with all overcommit memory policy

测试用例里面测试内存过载情况下的几种参数,默认,两倍默认,5%空闲内存,或者总内存的2%,理论上,这几个都不会导致机器hung死

其它知识

通过slabtop查看内核的缓存空间占用

[root@VM_0_17_centos ~]# slabtop -o|grep Total
Active / Total Objects (% used) : 550057 / 573695 (95.9%)
Active / Total Slabs (% used) : 22507 / 22507 (100.0%)
Active / Total Caches (% used) : 101 / 135 (74.8%)
Active / Total Size (% used) : 102508.62K / 106202.81K (96.5%)
[root@VM_0_17_centos ~]# grep Slab /proc/meminfo
Slab: 108676 kB
[root@VM_0_17_centos ~]# sysctl -a|grep min_free_kbytes
vm.min_free_kbytes = 45056

这个上面是腾讯云主机的,看到内核自身的占用应该在100M以上了,而我自己的vmware里面的虚拟机这个数值是47MB,这个数值可能跟不同的内核有关

系统还保留了一定的内存防止

Reserving 161MB of memory at 688MB for crashkernel (System RAM: 2047MB)

系统启动的时候看到的内存占用

[root@lab204 ~]# dmesg |grep Memory:
[ 0.000000] Memory: 1841584k/2097152k available (7784k kernel code, 524k absent, 255044k reserved, 5958k data, 1980k init)

内核文档关于这个参数的解释

https://www.kernel.org/doc/Documentation/sysctl/vm.txt

min_free_kbytes:

This is used to force the Linux VM to keep a minimum number
of kilobytes free. The VM uses this number to compute a
watermark[WMARK_MIN] value for each lowmem zone in the system.
Each lowmem zone gets a number of reserved free pages based
proportionally on its size. Some minimal amount of memory is needed to satisfy PF_MEMALLOC
allocations; if you set this to lower than 1024KB, your system will
become subtly broken, and prone to deadlock under high loads. Setting this too high will OOM your machine instantly.

基于以上暂时推测

建议能保留1G以上的空间

变更记录

Why Who When
创建 武汉-运维-磨渣 2020-09-09

关于vm.min_free_kbytes的合理设置推测的更多相关文章

  1. vm内核参数优化设置

     http://www.cnblogs.com/wjoyxt/archive/2014/06/08/3777042.html (1)vm.overcommit_memory 执行grep -i com ...

  2. 谨慎调整内核参数:vm.min_free_kbytes

    内核参数:内存相关 内存管理从三个层次管理内存,分别是node, zone ,page; 64位的x86物理机内存从高地址到低地址分为: Normal DMA32 DMA.随着地址降低. [root@ ...

  3. VM虚拟主机怎么设置网络

    VMware是很受欢迎的虚拟机,在我们平时的工作中需要经常用到,此文简单总结了平时使用的三种网络配置方式,具体的原理没有去深究.我估计咱也研究不懂! 虚拟主机安装很简单,网上教程有很多,但是有很多新手 ...

  4. Oracle VM VirtualBox 共享文件夹设置

    在Windows平台下,这货完全没有VMware好用,但在Linux平台就很好用. 学校机房的电脑打开虚拟机就不能插优盘,一插优盘就卡死,所以,只好用共享文件夹了. 1.在虚拟机外部新建一个文件夹 假 ...

  5. Oracle VM VirtualBox ubuntu 共享文件设置

    1.创建共享文件 2.在本机上选择共享文件路径,虚拟机设置共享文件名称,注意这里不能选择自动挂载 3. 虚拟机新建文件夹挂载共享文件 sudo mkdir /mnt/sharedsudo mount ...

  6. VM 虚拟机 CentOS 7 设置 桥接网络

    桥接网络的设置:   安装时设置网络为桥接网络!   找到 ip 地址,设置如下   注意ip地址并不是一样的,用以区分   然后在关闭 windows 防火墙,打开 cmd 使用 ping 命令 O ...

  7. VM中Linux网络设置(固定ip、连接外网开发环境)

      在开发过程中,我们经常需要在linux中进行操作.毕竟服务器的系统大多数都是Linux,所以在dev环境需要配置好一台Linux系统配合开发.   在VMWare Workstation Pro中 ...

  8. Oracle VM VirtualBox CentOS7桥接设置问题解决

    我遇到的问题是不能选择桥接网络选项,处理步骤: 1.重装 VirtualBox(安装DockerToolBox带的VirtualBox). 2.下面是存在的缺少驱动问题和解决方法: 注意 :缺少桥接驱 ...

  9. 虚拟机Mac系统中VMware_tools安装和vm共享文件夹的设置(转)

    原文来源: http://wenku.baidu.com/link?url=KRgfG40q2SEwZfde9xA7HVKjCsFBkMcf83tyellnzsHYZ_ErU1hWpVmTHYZem0 ...

随机推荐

  1. 数据库SQL Server 2016“功能选择”详细说明及精简安装选择

    前言 在平时大家安装数据库的时候,一般默认功能选择都会选择全选.但是前两天公司同事问我:"那么多功能为什么都能用到嘛?"顿时,我思考了一下确实没有详细了解每个功能的详细作用,于是花 ...

  2. 超简单的CDH6部署和体验(单机版)

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  3. harbor搭建与使用

        前两天测试服务docker化并k8s布署时,出于方便,使用了docker hub.由于我们的代码是要放到镜像里的,通过运行容器,便能获取我们的全部代码,风险很大.所以我们决定进行私有化的镜像部 ...

  4. kafka-伪集群搭建

      一.简介 Apache Kafka是一个快速.可扩展的.高吞吐的.可容错的分布式"发布-订阅"消息系统,使用Scala与Java语言编写,能够将消息从一个端点传递到另一个端点, ...

  5. BOOST 条件变量使用

    代码: // boost库 条件变量 使用测试 #include <iostream> #include <boost/thread.hpp> using namespace ...

  6. git 报错 error: failed to push some refs to .....

    git push 代码的时候报错,报错如下: 这种报错是因为远程仓库的代码和本地仓库的代码不同步,对本地的代码进行一次拉取,再 git push 就可以解决了 通过如下命令进行代码合并 git pul ...

  7. EF 表中中多次指定了列名解决办法

    这个问题是我们实际开发中遇到过的问题. 可能的原因:数据库在执行数据表迁移的时候,数据表执行成功,最后插入EF数据迁移表__MigrationHistory的时候,没有把所有的命令行完整插入,缺失了一 ...

  8. 布隆过滤器 Bloom Filter 2

    date: 2020-04-01 17:00:00 updated: 2020-04-01 17:00:00 Bloom Filter 布隆过滤器 之前的一版笔记 点此跳转 1. 什么是布隆过滤器 本 ...

  9. Java学习的第五十六天

    1.例11.5引用保护成员 public class Cjava { public static void main(String[]args) { Student1 s1=new Student1( ...

  10. 参悟python元类(又称metaclass)系列实战(一)

    写在前面 之前在看廖雪峰python系列的教程时,对元类的章节一直头大,总在思考我到底适不适合学习python,咋这么难,尤其是ORM的部分,倍受打击:后来从0到1手撸了一套ORM,才稍微进阶了一点理 ...