【大页内存】Oracle数据库配置大页内存
配置大页内存
脚本内容
#!/bin/bash## hugepages_settings.sh## Linux bash script to compute values for the# recommended HugePages/HugeTLB configuration# on Oracle Linux## 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 forthe recommended HugePages/HugeTLB configuration for the current sharedmemory 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 andyou should accommodate this while calculating the overall 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" ];thenecho "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]*"`doMIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`if [ $MIN_PG -gt 0 ]; thenNUM_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 ]; thenecho "***********"echo "** ERROR **"echo "***********"echo "Sorry! There are not enough total of shared memory segments allocated forHugePages configuration. HugePages can only be used for shared memory segmentsthat 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.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" ;;'3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;'3.10') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;'4.1') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;'4.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;'4.18') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;'5.4') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;*) echo "Kernel version $KERN is not supported by this script (yet). Exiting." ;;esac# End
开始配置
#运行,数据库开启状态chmod +x hugepages_settings.sh./hugepages_settings.sh# /etc/security/limits.conf 配置* soft memlock 60397977* hard memlock 60397977#/etc/sysctl.conf 配置,egvm.nr_hugepages = 1496sysctl -pgrep Huge /proc/meminfo#重启数据库
当然也可以使用参数来锁定数据库使用的内存,以防止其他程序使用。如数据库参数use_large_pages。
系统参数vm.hugetlb_shm_group 。如调整该参数,请反复确认

浙公网安备 33010602011771号