0927hugepages与nr_overcommit_hugepages

[20170927]hugepages与内核参数nr_overcommit_hugepages.txt

/proc/sys/vm/nr_overcommit_hugepages specifies how large the pool of huge pages can grow, if more huge pages than
/proc/sys/vm/nr_hugepages are requested by applications. Writing any non-zero value into this file indicates that the
hugetlb subsystem is allowed to try to obtain that number of "surplus" huge pages from the kernel's normal page pool,
when the persistent huge page pool is exhausted. As these surplus huge pages become unused, they are freed back to the
kernel's normal page pool.

--//从上面的说明可以看出设置这个参数可以减少hagepages的使用,避免设置过大导致的浪费.
--//我以前提到参数use_large_pages可以设置auto.参考链接:
--//  [20170313]11G use_large_pages参数.txt => http://blog.itpub.net/267265/viewspace-2135210/
--//  [20170516]11G use_large_pages参数2.txt => http://blog.itpub.net/267265/viewspace-2145480/

--//我提到设置参数use_large_pages=auto,虽然/etc/sysctl.conf配置vm.nr_hugepages = 105.
--//但是可以通过oradism命令启动修改内核参数.但是如果关闭数据库,我的测试配置的hugepage不会回收.

--//测试设置nr_overcommit_hugepages会发生什么情况?

1.环境:
# cat /proc/version
Linux version 2.6.39-300.26.1.el5uek (mockbuild@ca-build56.us.oracle.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-52)) #1 SMP Thu Jan 3 18:31:38 PST 2013

# cat /proc/sys/vm/nr_overcommit_hugepages
0
--//缺省是0.

# cat /proc/meminfo | grep -i hugepage
AnonHugePages:         0 kB
HugePages_Total:     305
HugePages_Free:       96
HugePages_Rsvd:       96
HugePages_Surp:      200
Hugepagesize:       2048 kB

--//数据库配置情况:
SCOTT@book> show sga
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes

SCOTT@book> show parameter use_large_pages
NAME            TYPE   VALUE
--------------- ------ -----
use_large_pages string AUTO

SYS@book> alter system set use_large_pages=only scope=spfile;
System altered.

--//如果参数为是Only,从含义上,表示Oracle实例只会使用HugePage作为内存使用。如果系统在AMM模式或者HugePage用尽的时候,数
--//据库就不能启动或者报错。

--//关闭数据库,修改/etc/sysctl.conf,再启动看看:
SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

--//修改/etc/sysctl.conf
vm.nr_hugepages = 105
vm.nr_overcommit_hugepages=1000

# sysctl -p

# cat /proc/meminfo | grep -i hugepage
AnonHugePages:         0 kB
HugePages_Total:     105
HugePages_Free:      105
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
--//现在HugePages_Total: 105

--//注意检查修改/etc/security/limits.conf内容:
oracle soft    memlock        unlimited
oracle hard    memlock        unlimited

--//再启动数据库看看:
SYS@book> startup
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.
Database opened.

--//可以发现现在可以正常启动!!检查alert文件:

Starting ORACLE instance (normal)
Specified value of sga_max_size is too small, bumping to 637534208
************************ Large Pages Information *******************
Parameter use_large_pages = ONLY
Per process system memlock (soft) limit = 51 GB
Total Shared Global Region in Large Pages = 610 MB (100%)
Large Pages used by this instance: 305 (610 MB)
Large Pages unused system wide = 0 (0 KB)
Large Pages configured system wide = 305 (610 MB)
Large Page size = 2048 KB
********************************************************************

--//可以发现我现在设置vm.nr_hugepages = 105,实际上使用305,但是数据库可以正常启动,而且use_large_pages = ONLY,也就是强制使
--//用hugepages.通过如下命令也可以发现:

# cat /proc/meminfo | grep -i hugepage
AnonHugePages:         0 kB
HugePages_Total:     305
HugePages_Free:       97
HugePages_Rsvd:       97
HugePages_Surp:      200
Hugepagesize:       2048 kB

SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

# cat /proc/meminfo | grep -i hugepage
AnonHugePages:         0 kB
HugePages_Total:     105
HugePages_Free:      105
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB

--//可以发现使用的hupepages回收了.也就是使用的内存空间回收了.这样的使用方式,可以一定程度避免内存浪费.

3.继续测试现在设置vm.nr_overcommit_hugepages=0.
--//修改/etc/sysctl.conf
vm.nr_hugepages = 105
vm.nr_overcommit_hugepages=0

# sysctl -p
# cat /proc/meminfo | grep -i hugepage
AnonHugePages:         0 kB
HugePages_Total:     105
HugePages_Free:      105
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB

SYS@book> startup
ORA-27137: unable to allocate large pages to create a shared memory segment
Linux-x86_64 Error: 12: Cannot allocate memory
Additional information: 624951296
Additional information: 1

--//可以这样无法获得足够的hugepages,数据库无法启动.修改回来后在启动正常.
vm.nr_overcommit_hugepages=1000

总结:
通过设置这个参数,一定程度避免内存浪费,必须设置大的hugepages,而导致一些内存浪费,而且不使用时可以回收.

时间: 2024-10-19 05:39:34

0927hugepages与nr_overcommit_hugepages的相关文章

[20170927]关于hugepages.txt

[20170927]关于hugepages.txt --//今天测试hugepages与内核参数nr_overcommit_hugepages,才发现HugePages_Surp表示什么? --// [20170209]理解pre_page_sga参数.txt  => http://blog.itpub.net/267265/viewspace-2145481/ --// 0927hugepages与nr_overcommit_hugepages =>http://blog.itpub.net

Linux系统性能指标

Linux内核提供的/proc/目录所提供的信息能够基本满足我们对当前主机性能指标的获取需求.现有网络上流传很多版本的对/proc/下文件各字段解释的blog,存在很多错误.本文结合最权威linux内核官方文档Linux Programer's Manual解释/proc/stat各字段的含义,原文档请参考:http://man7.org/linux/man-pages/man5/proc.5.html. 1.linux性能数据来源 1.1.cpu实时性能数据 /proc/stat 通过/pro

Linux传统Huge Pages与Transparent Huge Pages再次学习总结

  Linux下的大页分为两种类型:标准大页(Huge Pages)和透明大页(Transparent Huge Pages).Huge Pages有时候也翻译成大页/标准大页/传统大页,它们都是Huge Pages的不同中文翻译名而已,顺带提一下这个,免得有人被这些名词给混淆.误导了.Huge Pages是从Linux Kernel 2.6后被引入的.目的是使用更大的内存页面(memory page size) 以适应越来越大的系统内存,让操作系统可以支持现代硬件架构的大页面容量功能.透明大页

DBA不可不知的操作系统内核参数

背景 操作系统为了适应更多的硬件环境,许多初始的设置值,宽容度都很高. 如果不经调整,这些值可能无法适应HPC,或者硬件稍好些的环境. 无法发挥更好的硬件性能,甚至可能影响某些应用软件的使用,特别是数据库. 数据库关心的OS内核参数 512GB 内存为例 参数 fs.aio-max-nr 支持系统 CentOS 6, 7 参数解释 aio-nr & aio-max-nr: . aio-nr is the running total of the number of events specifie