- Set the vm.min_free_kbytes kernel parameter to reserve 512MB to allow the OS to reclaim memory faster and avoid LowMem pressure. See Document 452326.1, Document 452000.1 and Document 1367153.1 for additional information.
- Implement HugePages for the database instances. HugePages provides a method to have larger page sizes and it will lock the SGA into physical memory thus eliminating the need for system page table lookups for the SGA. This is especially important on systems with high memory allocations due to eliminate the management overhead associated with the such configurations. HugePages is also recommended in environments where server stability issues are evident – various spins/hangs, which are not attributed to Oracle Clusterware or other known OS issues. To compute size, see Document 401749.1. For more information, see Document 361323.1. In 11gR1 and above, you must disable AMM to use HugePages as directed in Document 749851.1.
- On kernel revision 2.6.18 and below set the kernel parameter vm.swappiness=100. Stress testing has shown that vm.swappiness = 100 (default = 60) on kernel version 2.6.18 or lower can reduce or delay node evictions under conditions of heavy memory pressure due to large numbers of client connections or during login storms.
内存参数设置:vm.min_free_kbytes
/proc/sys/vm/min_free_kbytes: This controls the amount of memory that is kept free for use by special reserves including “atomic” allocations (those which cannot wait for reclaim).
Setting vm.min_free_kbytes too low prevents the system from reclaiming memory. This can result in system hangs and OOM-killing multiple processes.
However, setting this parameter to a value that is too high (5-10% of total system memory) will cause your system to become out-of-memory immediately. Linux is designed to use all available RAM to cache file system data. Setting a high min_free_kbytes value results in the system spending too much time reclaiming memory.
From the O/S perspective, the parameter vm.min_free_kbytes should be initially set in the order of 0.5% of total physical memory. Refer to the MemTotal line in the /proc/meminfo report as one place to find this value.This value needs adjusting for every server, there is not a default value. Avoid attempting a setting that exceeds 5% of physical memory, which can trigger immediate out-of-memory conditions.
The new value should be added as follows:
- Open the file /etc/sysctl.conf
# vi /etc/sysctl.conf
- Add/modify the following line:
vm.min_free_kbytes = <value>
<value> should be replaced by the actual computed value.
- Save the file and run the following command to load the changes:
# sysctl -p /etc/sysctl.conf
Note: Before applying vm.min_free_kbytes tweak in Exadata, refer Oracle Exadata Database Machine Setup/Configuration Best Practices (Doc ID 1274318.1)
内存大页配置HugePages :
#!/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 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 -m
Press Enter to proceed..."
read
# 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}'`
if [ -z "$HPG_SZ" ];then
echo "The hugepages may not be supported 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 memory segments
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.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
vm.swappiness配置:
It is not unusual for memory that MySQL Server uses to be swapped out by the kernel, this does not necessarily mean there is a memory leak or that MySQL Server is using excessive memory. The kernel has a setting called vm.swappiness which controls how aggressively pages from main memory are swapped to disk in lieu of evicting pages from the page cache. The default setting is 60 and can cause this behavior on otherwise normal environments. If you are concerned and do not want the system to use swap during normal operation, set the vm.swappiness value to 1. This is done with the following command:
echo "vm.swappiness=1" >> /etc/sysctl.conf
sysctl -p




