Oracle rac 数据库优化HugePages

Posted 晴天薄雨荷

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle rac 数据库优化HugePages相关的知识,希望对你有一定的参考价值。


1 环境

服务器版本  [root@rac1 ~]# cat/etc/redhat-release

CentOS release 6.5 (Final)

数据库版本[oracle@rac2~]$ sqlplus -v

SQL*Plus: Release 11.2.0.4.0 Production

 

2 执行脚本

oracle@bd-stg-oracle-46:~$shhugepages_settings.sh

若HugePages配置可行,他就会推荐一个内存大小,若不可行则报错

#!/bin/bash

#

#hugepages_settings.sh

#

# Linuxbash script to compute values for the

#recommended HugePages/HugeTLB configuration

# onOracle Linux

#

# Note:This script does calculation for all shared memory

#segments available when the script is run, no matter it

# is anOracle RDBMS shared memory segment or not.

#

# Thisscript is provided by Doc ID 401749.1 from My Oracle Support

#http://support.oracle.com

 

# Welcometext

echo"

Thisscript is provided by Doc ID 401749.1 from My Oracle Support

(http://support.oracle.com)where it is intended to compute values for

therecommended HugePages/HugeTLB configuration for the current shared

memorysegments on Oracle Linux. Before proceeding with the execution please notefollowing:

 * For ASM instance, it needs to configure ASMMinstead of AMM.

 * The 'pga_aggregate_target' is outside theSGA and

   you should accommodate this whilecalculating SGA size.

 * In case you changes the DB SGA size,

   as the new SGA will not fit in the previousHugePages configuration,

   it had better disable the whole HugePages,

   start the DB with new SGA size and run thescript again.

And makesure that:

 * Oracle Database instance(s) are up andrunning

 * Oracle Database 11g Automatic MemoryManagement (AMM) is not setup

   (See Doc ID 749851.1)

 * The shared memory segments can be listed bycommand:

     # ipcs -m

 

 

PressEnter to proceed..."

read

 

# Checkfor the kernel version

KERN=`uname-r | awk -F. '{ printf("%d.%d\n",$1,$2); }'`

 

# Findout the HugePage size

HPG_SZ=`grepHugepagesize /proc/meminfo | awk '{print $2}'`

if [ -z"$HPG_SZ" ];then

    echo "The hugepages may not besupported in the system where the script is being executed."

    exit 1

fi

 

#Initialize the counter

NUM_PG=0

 

#Cumulative number of pages required to handle the running shared memorysegments

forSEG_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`

    fi

done

 

RES_BYTES=`echo"$NUM_PG * $HPG_SZ * 1024" | bc -q`

 

# An SGAless than 100MB does not make sense

# Bailout if that is the case

if [$RES_BYTES -lt 100000000 ]; then

    echo "***********"

    echo "** ERROR **"

    echo "***********"

    echo "Sorry! There are not enoughtotal of shared memory segments allocated for

HugePagesconfiguration. HugePages can only be used for shared memory segments

that youcan list by command:

 

    # ipcs -m

 

of a sizethat can match an Oracle Database SGA. Please make sure that:

 * Oracle Database instance is up and running

 * Oracle Database 11g Automatic MemoryManagement (AMM) is not configured"

    exit 1

fi

 

# Finishwith results

case$KERN in

    '2.2') echo "Kernel version $KERN isnot 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" ;;

    '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" ;;

esac

 

# End


3 修改配置文件

 根据执行结结果配置 /etc/sysctl.conf 文件,增加vm.nr_hugepages=12292

4  加载配置

[root@rac1 ~]# sysctl -p

net.ipv4.ip_forward = 0

net.ipv4.conf.default.rp_filter = 1

net.ipv4.conf.default.accept_source_route =0

kernel.sysrq = 0

kernel.core_uses_pid = 1

net.ipv4.tcp_syncookies = 1

error:"net.bridge.bridge-nf-call-ip6tables" is an unknown key

error:"net.bridge.bridge-nf-call-iptables" is an unknown key

error:"net.bridge.bridge-nf-call-arptables" is an unknown key

kernel.msgmnb = 65536

kernel.msgmax = 65536

kernel.shmmax = 68719476736

kernel.shmall = 4294967296

net.ipv4.ip_forward = 0

net.ipv4.conf.default.rp_filter = 1

net.ipv4.conf.default.accept_source_route =0

kernel.sysrq = 0

kernel.core_uses_pid = 1

net.ipv4.tcp_syncookies = 1

kernel.msgmnb = 65536

kernel.msgmax = 65536

kernel.shmmax = 68719476736

kernel.shmall = 4294967296

kernel.shmmni = 4096

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

net.ipv4.tcp_wmem = 262144 262144 262144

net.ipv4.tcp_rmem = 4194304 4194304 4194304

 

vm.nr_hugepages = 12292

5 查看配置


 

 


以上是关于Oracle rac 数据库优化HugePages的主要内容,如果未能解决你的问题,请参考以下文章

linux7.4开启hugepages

经典资料 | Oracle RAC 建设过程中各个层面的关键点和优化项总结

THP Transparent HugePages 相关知识与关闭

oracle rac是啥

oracle数据库rac是啥

oracle10双机rac停机