[20160516]11G HugePage的使用问题.txt
--我们的dg内存不足,配置的/etc/sysctl.conf如下:
vm.nr_hugepages = 3200
--没有启动数据库前如下:
# grep -i huge /proc/meminfo
AnonHugePages: 14336 kB
HugePages_Total: 3200
HugePages_Free: 3200
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
--3200*2=6400M,也就是配置了6G上下给HugePAGE,而我们数据库原来的参数很大,达到SGA_TAGGET=76G,正常不会HUPEGE.
--启动数据库后:
SYS@dbcn1> startup open read only
ORACLE instance started.
Total System Global Area 8.0973E+10 bytes
Fixed Size 2261968 bytes
Variable Size 9932114992 bytes
Database Buffers 7.0867E+10 bytes
Redo Buffers 171487232 bytes
Database mounted.
Database opened.
SYS@dbcn1> show parameter sga_
NAME TYPE VALUE
------------- ------------ --------
sga_max_size big integer 77568M
sga_target big integer 77568M
# grep -i huge /proc/meminfo
AnonHugePages: 26624 kB
HugePages_Total: 3200
HugePages_Free: 3003
HugePages_Rsvd: 3003
HugePages_Surp: 0
Hugepagesize: 2048 kB
--你可以发现依旧使用HUGEPAGE.检查alert*.log文件:
************************ Large Pages Information *******************
Per process system memlock (soft) limit = 58 GB
Total Shared Global Region in Large Pages = 6400 MB (8%)
Large Pages used by this instance: 3200 (6400 MB)
Large Pages unused system wide = 0 (0 KB)
Large Pages configured system wide = 3200 (6400 MB)
Large Page size = 2048 KB
RECOMMENDATION:
Total System Global Area size is 76 GB. For optimal performance,
prior to the next instance restart:
1. Increase the number of unused large pages by
at least 35585 (page size 2048 KB, total size 70 GB) system wide to
get 100% of the System Global Area allocated with large pages
2. Large pages are automatically locked into physical memory.
Increase the per process memlock (soft) limit to at least 76 GB to lock
100% System Global Area's large pages into physical memory
********************************************************************
--换一句话讲及时即使你配置不足,oracle也会使用它.不知道从那个版本开始支持这个特性.
这个情况在11.2.0.3版本中有一些变化。Oracle首先会使用可用的HugePage,如果使用尽了,同样会采用剩下的small pages作为SGA使用
。变化在于对使用HugePage的方式上,根据官方的说法:
With this new behavior additional shared memory segments are an expected side effect. Part of the change is to ensure
that each shared memory segment making up the SGA only contains sub-areas with an identical alignment requirement -
hence the SGA will spread over more separate SHM segments. In this supported mixed page mode the database will exhaust
the available hugepages, before switching to regular sized pages.
--另外必须注意一个问题,如果设置不用这些内存不用就浪费了.
--假设设置
vm.nr_hugepages = 26000
# free -m
total used free shared buffers cached
Mem: 129161 41066 88094 0 892 31060
-/+ buffers/cache: 9113 120047
Swap: 30718 0 30718
# sysctl -p
# free -m
total used free shared buffers cached
Mem: 129161 86665 42495 0 892 31060
-/+ buffers/cache: 54713 74448
Swap: 30718 0 30718
--内存马上使用45G,free也减少了.这个在配置时注意,假设你设置了以上参数,数据库又没有重启,这样不会使用hugepage,双重内存使用,内存很快会耗尽.