在Oracle 11.2.0.3.0上开启大页(hugepages)的详细解析

浏览:
字体:
发布时间:2013-12-09 23:24:03
来源:

转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/17138391

什么时侯使用大页呢,当你主机的物理内存为64G,设SGA>=32G时,建议开启大页,步骤如下:

1、 关闭Oracle Database 11g中的AMM(Automatic Memory Management),即把两个参数MEMORY_TARGET / MEMORY_MAX_TARGET设为0

如果设考数 MEMORY_MAX_TARGET为0不成功,那么请考参http://blog.csdn.net/guoyjoe/article/details/12845965

gyj@OCM> show parameter memory_max_targetNAME                                 TYPE        VALUE------------------------------------ ----------- ------------------------------memory_max_target                    big integer 0gyj@OCM> show parameter memory_targetNAME                                 TYPE        VALUE------------------------------------ ----------- ------------------------------memory_target                        big integer 0

2、参考metalink(文档 ID 401749.1)提供的脚本,计算hugepages的大小

#!/bin/bash## hugepages_settings.sh## Linux bash script to compute values for the# recommended HugePages/HugeTLB configuration## Note: This script does calculation for all shared memory# segments available when the script is run, no matter it# is an Oracle RDBMS shared memory segment or not.## This script is provided by Doc ID 401749.1 from My Oracle Support # http://support.oracle.com# Welcome textecho "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. 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 -mPress Enter to proceed..."read# Check for the kernel versionKERN=`uname -r | awk -F. '{ printf("%d.%d/n",$1,$2); }'`# Find out the HugePage sizeHPG_SZ=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`if [ -z "$HPG_SZ" ];then    echo "The hugepages may not be supported in the system where the script is being executed."    exit 1fi# Initialize the counterNUM_PG=0# Cumulative number of pages required to handle the running shared memory segmentsfor SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | grep "[0-9][0-9]*"`do    MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`    if [ $MIN_PG -gt 0 ]; then        NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`    fidoneRES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`# An SGA less than 100MB does not make sense# Bail out if that is the caseif [ $RES_BYTES -lt 100000000 ]; then    echo "***********"    echo "** ERROR **"    echo "***********"    echo "Sorry! There are not enough total of shared memory segments allocated for HugePages configuration. HugePages can only be used for shared memory segments that you can list by command:    # ipcs -mof a size that can match an Oracle Database SGA. Please make sure that: * Oracle Database instance is up and running  * Oracle Database 11g Automatic Memory Management (AMM) is not configured"    exit 1fi# Finish with resultscase $KERN in    '2.2') echo "Kernel version $KERN is not supported. Exiting." ;;    '2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;           echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;    '2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;esac# End

[oracle@mydb admin]$ chmod +x 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. 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 -mPress Enter to proceed...Recommended setting: vm.nr_hugepages = 1028

gyj@OCM> show parameter sga_max_size


5、设置hugepages,在内核参数中添加一行,vi /etc/sysctl.conf

vm.nr_hugepages = 1028


6、修改内核参数立即生效

net.ipv4.ip_forward = 0net.ipv4.conf.default.rp_filter = 1net.ipv4.conf.default.accept_source_route = 0kernel.sysrq = 0kernel.core_uses_pid = 1net.ipv4.tcp_syncookies = 1kernel.msgmnb = 65536kernel.msgmax = 65536kernel.shmmax = 68719476736kernel.shmall = 4294967296fs.file-max = 6815744vm.nr_hugepages = 1028

[root@mydb ~]# vi /etc/security/limits.conf

oracle soft memlock 2056000


8、检查limits是否正确

9、重启数据库---注原来的orale用户的窗口退到root用户,重新su - oracle

sys@OCM> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options[oracle@mydb ~]$ exitlogoutYou have new mail in /var/spool/mail/root[root@mydb ~]# su -  oracle[oracle@mydb ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Thu Dec 5 10:56:20 2013Copyright (c) 1982, 2011, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionssys@OCM> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.sys@OCM> startupORACLE instance started.Total System Global Area 2137886720 bytesFixed Size                  2230072 bytesVariable Size            1409288392 bytesDatabase Buffers          603979776 bytesRedo Buffers              122388480 bytesDatabase mounted.Database opened.

[oracle@mydb ~]$ watch -n1 'cat /proc/meminfo |grep -i HugePage'

Every 1.0s: cat /proc/meminfo |grep -i HugePage                                                   Thu Dec  5 11:09:06 2013HugePages_Total:  1028HugePages_Free:    869HugePages_Rsvd:    842Hugepagesize:     2048 kB

sys@OCM> alter system set pre_page_sga=true scope=spfile;System altered.sys@OCM> show parameter sgaNAME                                 TYPE        VALUE------------------------------------ ----------- ------------------------------lock_sga                             boolean     FALSEpre_page_sga                         boolean     TRUEsga_max_size                         big integer 2Gsga_target                           big integer 1G

For 11.2.0.2 and further, the Oracle Database Server has added a new parameter that helps managing the hugepages for use by the database.


补充关于内存申请的OverCommit:

Linux下的OverCommit机制,主要是为了应对可能的异常的大量内存申请对OS本身造成冲击。

[root@mydb vm]# cd /proc/sys/vm[root@mydb vm]# lsblock_dump                 flush_mmap_pages      min_free_kbytes     overcommit_memory         swappinessdirty_background_ratio     hugetlb_shm_group     min_slab_ratio      overcommit_ratio          swap_token_timeoutdirty_expire_centisecs     laptop_mode           min_unmapped_ratio  pagecache                 vfs_cache_pressuredirty_ratio                legacy_va_layout      mmap_min_addr       page-cluster              zone_reclaim_modedirty_writeback_centisecs  lowmem_reserve_ratio  nr_hugepages        panic_on_oomdrop_caches                max_map_count         nr_pdflush_threads  percpu_pagelist_fraction
假设操作系统只有1000M内存,有个应用请求操作系统需要1200M内存,操作系统会承诺给1200M,即由OverCommit承诺,这时还没有真正分配空间。
>更多相关文章
24小时热门资讯
24小时回复排行
资讯 | QQ | 安全 | 编程 | 数据库 | 系统 | 网络 | 考试 | 站长 | 关于东联 | 安全雇佣 | 搞笑视频大全 | 微信学院 | 视频课程 |
关于我们 | 联系我们 | 广告服务 | 免责申明 | 作品发布 | 网站地图 | 官方微博 | 技术培训
Copyright © 2007 - 2024 Vm888.Com. All Rights Reserved
粤公网安备 44060402001498号 粤ICP备19097316号 请遵循相关法律法规
');})();