当前位置:数据库 > Oracle >>

linux的hugepage的配置-优化oracle内存

linux的hugepage的配置-优化oracle内存
 
linux虽然没有aix,hp unix那么强悍,但linux也是非常优秀的,为了提升linux的性能,它采用了很多
io,memory的调度机制,linux使用内存的方式是采用vm的方式,即linux把物理内存和swap共同虚拟成
内存来对外提供,有时用户看似使用内存,可实际上是使用磁盘,那如何避免使用swap磁盘空间呢?
linux管理内存的单位是页(pages),一般情况下是4k的page,当我们使用的大内存时(>8G),管理这么大的内存
就会给系统造成很大的负担,再加上频繁的pagein/pageout,会成为系统的瓶颈。
 
1.hugepage介绍
2.实践配置
 
1.hugepage介绍
hugepage是在linux2.6内核被引入的,主要提供4k的page和比较大的page的选择
当我们访问内存时,首先访问”page table“,然后linux在通过“page table”的
mapping来访问真实物理内存(ram+swap)。为了提升性能,linux在cpu中申请
固定大小的buffer,被称为TLB,TLB中保存有“page table”的部分内容,这也遵循
了,让数据尽可能的靠近cpu原则。在TLB中通过hugetlb来指向hugepage。这些被分配
的hugepage作为内存文件系统hugetlbfs(类似tmpfs)提供给进程使用。
普通4k page
 
启用hugepage
 
hugepage特点
linux系统启动,hugepage就被分配并保留,不会pagein/pageout,除非人为干预,如改变hugepage的配置等;
根据linux内核的版本和HW的架构,hugepage的大小从2M到256M不等。因为采用大page,所以也减少TLB
和page table的管理压力
为什么使用hugepage
对于大内存(>8G),hugepage对于提高在linux上的oracle性能是非常有帮助的
 1)Larger Page Size and Less of Pages:减少了HugeTLB 的工作量
 2)No Page Table Lookups:因为hugepage是不swappable的,所有就没有page table lookups。
 3)No Swapping: 在Linux下,hugepage是不支持swapping
 4)No 'kswapd' Operations:在linux下进程“kswapd”是管理swap的,如果是大内存,那pages的数量就非常大, 那“kswapd”就会被频繁的调用,从而会影响性能。
 
1) 配置之前
[oracle@db101 ~]$ grep HugePages /proc/meminfo
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     2048 kB
 
 
(2) 首先修改limits.conf
[root@db101 ~]# vi /etc/security/limits.conf  
## 等于SGA_MAX_SIZE  下面是KB 锁定15G内存
##zengmuansha add  0122
oracle   soft   memlock    15826672
oracle   hard   memlock    15826672
(3) [ORACLE 11G] 必须关闭AMM(自动内存管理)特性才能使用hugepage
设置如下初始化参数:
ALTER SYSTEM SET sga_max_size=15455M SCOPE=SPFILE;
ALTER SYSTEM SET sga_target=0 SCOPE=SPFILE;
ALTER SYSTEM SET PGA_AGGREGATE_TARGET=2048M SCOPE=SPFILE;
ALTER SYSTEM SET memory_target=0 SCOPE=SPFILE;
ALTER SYSTEM SET memory_max_target=0 SCOPE=SPFILE;
 
(4) 配置分配hugepage的数量
nr_hugepages的计算公式:nr_hugepages>=sga(mb)/Hugepagesize(mb)
echo "vm.nr_hugepages=3872" >> /etc/sysctl.conf
 
(5) 重启系统
reboot
(6) 启动数据库
sqlplus / as sysba
startup
(7) 检查是否生效
root@db101:[/root]grep HugePages  /proc/meminfo
HugePages_Total:  3890
HugePages_Free:     17
HugePages_Rsvd:      0
 
为了确保HugePages配置的有效性,HugePages_Free值应该小于HugePages_Total 的值,并且应该等于HugePages_Rsvd的值。
Hugepages_Free 和HugePages_Rsvd 的值应该小于SGA 分配的gages。
 
2.8 故障处理
一些常见的问题如下:
Symptom
Possible Cause
Troubleshooting Action
System is running out of memory or swapping Not enough HugePages to cover the SGA(s) and therefore the area reserved for HugePages are wasted where SGAs are allocated through regular pages
Review your HugePages configuration to make sure that all SGA(s) are covered.
Databases fail to start
memlock limits are not set properly
Make sure the settings in limits.conf apply to database owner account.
One of the database fail to start while another is up
The SGA of the specific database could not find available HugePages and remaining RAM is not enough.
Make sure that the RAM and HugePages are enough to cover all your database SGAs
Cluster Ready Services (CRS) fail to start
HugePages configured too large (maybe larger than installed RAM)
Make sure the total SGA is less than the installed RAM and re-calculate HugePages.
HugePages_Total = HugePages_Free
HugePages are not used at all. No database instances are up or using AMM.
Disable AMM and make sure that the database instances are up.
Database started successfully and the performance is slow
The SGA of the specific database could not find available HugePages and therefore the SGA is handled by regular pages, which leads to slow performance
Make sure that the HugePages are many enough to cover all your database SGAs
 
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,