Tuesday, January 26, 2016

How to enable HugePages on Linux

How to Configure HugePages on RedHat Enterprise Linux 5?



  • First check whether it is enabled:


[root@nestrac1 ~]# grep Huge /proc/meminfo
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     2048 kB


HugePages is not enabled...



  • Use the following script to obtain the value for "vm.nr_hugepages" . To use this scipt, insert into a file, make it executable and run it with oracle user:


#!/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.
# Check for the kernel version
KERN=`uname -r | awk -F. '{ printf("%d.%d\n",$1,$2); }'`
# Find out the HugePage size
HPG_SZ=`grep Hugepagesize /proc/meminfo | awk {'print $2'}`
# Start from 1 pages to be on the safe side and guarantee 1 free HugePage
NUM_PG=1
# Cumulative number of pages required to handle the running shared memory segments
for SEG_BYTES in `ipcs -m | awk {'print $5'} | 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
# Finish with results
case $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" ;;
    *) echo "Unrecognized kernel version $KERN. Exiting." ;;
esac

# End



  • Script output should be like the following:


$ ./hugepages_setting.sh 

Recommended setting: vm.nr_hugepages = 14462



  • Add this result value to /etc/sysctl.conf file


vm.nr_hugepages=14462



  • Reboot server..




  • After reboot HugePages is used as follows:


[root@exafkmdbadm01 ~]# grep Huge /proc/meminfo
HugePages_Total:   14462
HugePages_Free:     3736
HugePages_Rsvd:     3736
HugePages_Surp:        0
Hugepagesize:       2048 kB




** Make sure you have memlock values at /etc/security/limits.conf. For example If you have 64G RAM you should set it to slightly lesser values.


oracle   soft   memlock    60397977

oracle   hard   memlock    60397977


** Make sure you set the database parameters memory_% to "0" and use SGA, PGA values instead.

SQL> show parameter target

NAME                                 TYPE          VALUE
----------------------              ---------      -------
memory_max_target                    big integer      0
memory_target                        big integer      0
pga_aggregate_target                 big integer      1300M
sga_target                           big integer      3000M












No comments:

Post a Comment

Note: Only a member of this blog may post a comment.