linux开启huge page

  HugePages是linux内核的一个特性,使用hugepage可以用更大的内存页来取代传统的4K页面。使用HugePage主要带来如下好处


   1,没有swap。Notswappable: HugePages are not swappable. Therefore there is no page-in/page-outmechanism overhead.HugePages are universally regarded as pinned.


   2,减轻快表压力。Reliefof TLB pressure:TLB表格的更小了,效率提高


   3,减轻换页表的负载。每个表单需64字节,如果管理50GB的物理内存,如果使用传统4K页面pagetable需要800M大小,而是用HugePages仅需要40M


   4,提高内存的性能,降低CPU负载,原理同上


HugePages和oracle AMM(自动内存管理)是互斥的,所有使用HugePages必须设置内存参数MEMORY_TARGET / MEMORY_MAX_TARGET 为0




大概的意思就是,当系统连接数变多的时候, 系统 就没有内存了,然后就使用硬盘做内存,然后再释放内存后暂时缓解,往复如此. 使系统性能摇摆不定.




配置HugePages


1.修改内核参数memlock,单位是KB,memlock的大小要稍微小于物理内存. 就按 90%系统内存进行配置吧.
cat /etc/security/limits.conf


SQL> select 32234 * 1024 * 0.9 from dual;


32234*1024*0.9
--------------
    29706854.4
    


*  soft   memlock    29706854
*  hard   memlock    29706854


# Oracle-Validated setting for memlock soft limit is 50000000
#oracle   soft   memlock    50000000


# Oracle-Validated setting for memlock hard limit is 50000000
#oracle   hard   memlock    50000000


*代表所有用户,所以就把oracle 的设置注释掉 保存一下


2.进行验证


[oracle@jcdmskfdb2 ~]$ ulimit -a|grep lock
core file size          (blocks, -c) 0
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) 29706854
file locks                      (-x) unlimited


目测应该是可以了


3.对数据库的AMM进行处理




SQL> alter system reset memory_target scope=spfile;


系统已更改。


SQL> alter system reset memory_max_target scope=spfile;


系统已更改。


SQL> alter system set sga_target=12G scope=spfile;


系统已更改。


SQL> alter system set pga_aggregate_target=4G scope=spfile;


系统已更改。


4.计算 hugepage页面的大小
文档 Oracle Linux: Shell Script to Calculate Values Recommended Linux HugePages / HugeTLB Configuration (文档 ID 401749.1)




[root@jcdmskfdb2 u01]# sh hugepages_settings.sh 


This script is provided by Doc ID 401749.1 from My Oracle Support 
(http://support.oracle.com) where it is intended to compute values for 
the recommended HugePages/HugeTLB configuration for the current shared 
memory segments on Oracle Linux. Before proceeding with the execution please note following:
 * For ASM instance, it needs to configure ASMM instead of AMM.
 * The 'pga_aggregate_target' is outside the SGA and 
   you should accommodate this while calculating SGA size.
 * In case you changes the DB SGA size, 
   as the new SGA will not fit in the previous HugePages configuration, 
   it had better disable the whole HugePages, 
   start the DB with new SGA size and run the script again.
And make sure that:
 * Oracle Database instance(s) are up and running
 * Oracle Database 11g Automatic Memory Management (AMM) is not setup 
   (See Doc ID 749851.1)
 * The shared memory segments can be listed by command:
     # ipcs -m




Press Enter to proceed...


Recommended setting: vm.nr_hugepages = 6171




脚本已经给出了建立  6171


5.修改vm.nr_hugepages参数


vi /etc/sysctl.conf


vm.nr_hugepages = 6171


sysctl -p


验证一下


[oracle@jcdmskfdb2 u01]$ grep HugePages /proc/meminfo
HugePages_Total:    6171
HugePages_Free:     6171
HugePages_Rsvd:        0
HugePages_Surp:        0


好了,现在让你们的数据库,自由的去嗨吧


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7569309/viewspace-2135109/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7569309/viewspace-2135109/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值