linux7.4開啟hugepages


 

 

環境檢查

數據庫內存超過4G時,使用dbca建庫默認選項AMM是關閉的,內存超過8G時,oracle推薦使用hugepages,它可以將部分數據鎖定在內存中,處理效率比較高、性能好。

 

確認服務器物理內存已經超過8G,是大內存

確認數據庫實例沒有使用AMMhugepagesAMM不同時使用

Memlock

如果/etc/security/limits.d/*.conf中沒有關於memlock參數的設置,那么

memlock的值介於SGA與物理內存之間,比SGA大,比物理內存小

推薦值SGA+PGA為物理內存80%memlock為物理內存90%

Memlock = 物理內存*90%*1024*1024

 

vim /etc/security/limits.conf

oracle soft memlock 237363200

oracle hard memlock 237363200

 

# su - oracle

$ ulimit -l

237363200

 

腳本獲取推薦值

chmod +x hugepages_settings.sh

[root@crcsn1 scripts]# ./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 = 72708

[root@crcsn1 scripts]# ipcs -m

 

------ Shared Memory Segments --------

key        shmid      owner      perms      bytes      nattch     status      

0x00000000 1245184    grid       600        4096       0                       

0x00000000 1277953    grid       600        4096       0                       

0x4dfc72ac 1310722    grid       600        24576      48                      

0x00000000 1343491    grid       600        8802304    124                     

0x00000000 1376260    grid       600        1056964608 62                      

0x00000000 1409029    grid       600        7974912    62                      

0xef940690 1441798    grid       600        20480      62                      

0x00000000 2129927    oracle     600        30035968   614                     

0x00000000 2162696    oracle     600        150860726272 307                     

0x00000000 2195465    oracle     600        506834944  307                     

0x51c60604 2228234    oracle     600        24576      307

 

設置hugepages

 

# vim /etc/sysctl.conf

vm.nr_hugepages = 72708

 

# sysctl -p

 

# grep HugePages /proc/meminfo

AnonHugePages:   1093632 kB

HugePages_Total:   61313

HugePages_Free:    61313

HugePages_Rsvd:        0

HugePages_Surp:        0

 

 

附件

hugepages_settings.sh

#!/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 text

echo "

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..."

 

read

 

# Check for the kernel version

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

...skipping...

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

    fi

done

 

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

 

# An SGA less than 100MB does not make sense

# Bail out if that is the case

if [ $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 -m

 

of 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 1

fi

 

# Finish with results

case $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" ;;

    '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

 

參考

  1. HugePages on Oracle Linux 64-bit (文檔 ID 361468.1)
  2. Oracle Linux: Shell Script to Calculate Values Recommended Linux HugePages / HugeTLB Configuration (文檔 ID 401749.1)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM