Linux系统下快速配置HugePages的完整步骤
前言
关于Linux系统的HugePages与Oracle数据库优化,可以参考熊爷之前的文章,相关概念介绍的非常清晰:
Linux大内存页Oracle数据库优化
本文旨在Linux系统上快速配置HugePages
测试环境:RHEL6.8+512G物理内存;Oracle11.2.0.4SGA=400G.
1.设置memlock无限制
在/etc/security/limits.conf配置文件中,设置oracle用户memlock无限制:
vi/etc/security/limits.conf
oraclesoftmemlockunlimited oraclehardmemlockunlimited
2.设置合理的vm.nr_hugepages
在/etc/sysctl.conf配置文件中,设置合理的vm.nr_hugepages值。
运行MOS401749.1提供的hugepages_settings.sh脚本,直接可以得到建议值。
hugepages_settings.sh脚本内容:
#!/bin/bash # #hugepages_settings.sh # #Linuxbashscripttocomputevaluesforthe #recommendedHugePages/HugeTLBconfiguration #onOracleLinux # #Note:Thisscriptdoescalculationforallsharedmemory #segmentsavailablewhenthescriptisrun,nomatterit #isanOracleRDBMSsharedmemorysegmentornot. # #ThisscriptisprovidedbyDocID401749.1fromMyOracleSupport #http://support.oracle.com #Welcometext echo" ThisscriptisprovidedbyDocID401749.1fromMyOracleSupport (http://support.oracle.com)whereitisintendedtocomputevaluesfor therecommendedHugePages/HugeTLBconfigurationforthecurrentshared memorysegmentsonOracleLinux.Beforeproceedingwiththeexecutionpleasenotefollowing: *ForASMinstance,itneedstoconfigureASMMinsteadofAMM. *The'pga_aggregate_target'isoutsidetheSGAand youshouldaccommodatethiswhilecalculatingSGAsize. *IncaseyouchangestheDBSGAsize, asthenewSGAwillnotfitinthepreviousHugePagesconfiguration, ithadbetterdisablethewholeHugePages, starttheDBwithnewSGAsizeandrunthescriptagain. Andmakesurethat: *OracleDatabaseinstance(s)areupandrunning *OracleDatabase11gAutomaticMemoryManagement(AMM)isnotsetup (SeeDocID749851.1) *Thesharedmemorysegmentscanbelistedbycommand: #ipcs-m PressEntertoproceed..." read #Checkforthekernelversion KERN=`uname-r|awk-F.'{printf("%d.%d\n",$1,$2);}'` #FindouttheHugePagesize HPG_SZ=`grepHugepagesize/proc/meminfo|awk'{print$2}'` if[-z"$HPG_SZ"];then echo"Thehugepagesmaynotbesupportedinthesystemwherethescriptisbeingexecuted." exit1 fi #Initializethecounter NUM_PG=0 #Cumulativenumberofpagesrequiredtohandletherunningsharedmemorysegments forSEG_BYTESin`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-gt0];then NUM_PG=`echo"$NUM_PG+$MIN_PG+1"|bc-q` fi done RES_BYTES=`echo"$NUM_PG*$HPG_SZ*1024"|bc-q` #AnSGAlessthan100MBdoesnotmakesense #Bailoutifthatisthecase if[$RES_BYTES-lt100000000];then echo"***********" echo"**ERROR**" echo"***********" echo"Sorry!Therearenotenoughtotalofsharedmemorysegmentsallocatedfor HugePagesconfiguration.HugePagescanonlybeusedforsharedmemorysegments thatyoucanlistbycommand: #ipcs-m ofasizethatcanmatchanOracleDatabaseSGA.Pleasemakesurethat: *OracleDatabaseinstanceisupandrunning *OracleDatabase11gAutomaticMemoryManagement(AMM)isnotconfigured" exit1 fi #Finishwithresults case$KERNin '2.2')echo"Kernelversion$KERNisnotsupported.Exiting.";; '2.4')HUGETLB_POOL=`echo"$NUM_PG*$HPG_SZ/1024"|bc-q`; echo"Recommendedsetting:vm.hugetlb_pool=$HUGETLB_POOL";; '2.6')echo"Recommendedsetting:vm.nr_hugepages=$NUM_PG";; '3.8')echo"Recommendedsetting:vm.nr_hugepages=$NUM_PG";; '3.10')echo"Recommendedsetting:vm.nr_hugepages=$NUM_PG";; '4.1')echo"Recommendedsetting:vm.nr_hugepages=$NUM_PG";; esac #End
直接运行脚本即可得到对应的建议:
--当启动的实例设置SGA_MAX_SIZE=12G,给出建议: Recommendedsetting:vm.nr_hugepages=6148 --当启动的实例设置SGA_MAX_SIZE=400G,给出建议: Recommendedsetting:vm.nr_hugepages=204805 --当没有启动实例时,会报错提示: *********** **ERROR** *********** Sorry!Therearenotenoughtotalofsharedmemorysegmentsallocatedfor HugePagesconfiguration.HugePagescanonlybeusedforsharedmemorysegments thatyoucanlistbycommand: #ipcs-m ofasizethatcanmatchanOracleDatabaseSGA.Pleasemakesurethat: *OracleDatabaseinstanceisupandrunning *OracleDatabase11gAutomaticMemoryManagement(AMM)isnotconfigured
我这里将建议值vm.nr_hugepages=204805追加到/etc/sysctl.conf配置文件中,然后执行sysctl-p生效配置。
3.确认HugePages设置成功
查看关于HugePages的信息,注意HugePages_Total值是之前设置的204805:
grepHuge/proc/meminfo
#grepHuge/proc/meminfo AnonHugePages:0kB HugePages_Total:204805 HugePages_Free:168475 HugePages_Rsvd:168471 HugePages_Surp:0 Hugepagesize:2048kB
数据库在启动时,对应alert日志中会有“LargePagesInformation”内容:
WedNov1414:38:122018 StartingORACLEinstance(normal) ************************LargePagesInformation******************* Perprocesssystemmemlock(soft)limit=UNLIMITED TotalSharedGlobalRegioninLargePages=400GB(100%) LargePagesusedbythisinstance:204801(400GB) LargePagesunusedsystemwide=4(8192KB) LargePagesconfiguredsystemwide=204805(400GB) LargePagesize=2048KB ********************************************************************
至此可以确认HugePages设置成功。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对毛票票的支持。