您的位置:首页 > 运维架构 > Linux

linux系统性能相关参数介绍

2016-09-19 13:54 435 查看
Linux系统cache的释放:

通过文件/proc/sys/vm/drop_caches来控制已使用内存的控制:

控制已经使用cache的释放方式:

drop_caches的详细文档如下:

Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.

To free pagecache:

* echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:

* echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:

* echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation, and dirty objects are notfreeable, the user should run “sync” first in order to make sure allcached objects are freed.

This tunable was added in 2.6.16.

/proc/sys/vm/min_free_kbytes


该文件表示强制Linux VM最低保留多少空闲内存(Kbytes)。

缺省设置:724(512M物理内存)

/proc/sys/vm/overcommit_memory


该文件指定了内核针对内存分配的策略,其值可以是0、1、2。

0, 表示内核将检查是否有足够的可用内存供应用进程使用;如果有足够的可用内存,内存申请允许;否则,内存申请失败,并把错误返回给应用进程。

1, 表示内核允许分配所有的物理内存,而不管当前的内存状态如何。

2, 表示内核允许分配超过所有物理内存和交换空间总和的内存(参照overcommit_ratio)。

缺省设置:0

/proc/sys/vm/overcommit_ratio


该文件表示,如果overcommit_memory=2,可以过载内存的百分比,通过以下公式来计算系统整体可用内存。

系统可分配内存=交换空间+物理内存*overcommit_ratio/100

/proc/sys/vm/swapiness


该文件表示系统进行交换行为的程度,数值(0-100)越高,越可能发生磁盘交换。

/proc/sys/vm/vfs_cache_pressure


该文件表示内核回收用于directory和inode cache内存的倾向

/proc/sys/vm/page-cluster


该文件表示在写一次到swap区的时候写入的页面数量,0表示1页,1表示2页,2表示4页。

缺省设置:3(2的3次方,8页)

关于page cache一些相关系统参数设置

vm.dirty_background_ratio:

is the percentage of system memory that can be filled with “dirty” pages — memory pages that still need to be written to disk — before the pdflush/flush/kdmflush background processes kick in to write it to disk. My example is 10%, so if my virtual server has 32 GB of memory that’s 3.2 GB of data that can be sitting in RAM before something is done.

vm.dirty_ratio:

is the absolute maximum amount of system memory that can be filled with dirty pages before everything must get committed to disk. When the system gets to this point all new I/O blocks until dirty pages have been written to disk. This is often the source of long I/O pauses, but is a safeguard against too much data being cached unsafely in memory.

vm.dirty_background_bytes & vm.dirty_bytes:

are another way to specify these parameters. If you set the _bytes version the _ratio version will become 0, and vice-versa.

vm.dirty_expire_centisecs:

is how long something can be in cache before it needs to be written. In this case it’s 30 seconds. When the pdflush/flush/kdmflush processes kick in they will check to see how old a dirty page is, and if it’s older than this value it’ll be written asynchronously to disk. Since holding a dirty page in memory is unsafe this is also a safeguard against data loss.

vm.dirty_writeback_centisecs:

is how often the pdflush/flush/kdmflush processes wake up and check to see if work needs to be done.

动态修改系统配置参数,立刻生效,但不具有持久性(系统重启就会丢失)

$echo {parameters} /proc/sys/vm/{options}
or
$sysctl  -w variable=value


修改sysctl.conf系统配置文件,然后执行sysctl -p,重新加载生效,具有持久性:

$vim /etc/sysctl.conf
$sysctl -p
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: