Linux��Ȼû��aix��hp unix��ôǿ������LinuxҲ�Ƿdz�����ģ�Ϊ������Linux�����ܣ��������˺ܶ�io��memory�ĵ��Ȼ��ƣ�Linuxʹ���ڴ�ķ�ʽ�Dz���vm�ķ�ʽ����Linux�������ڴ��swap��ͬ������ڴ��������ṩ����ʱ�û�����ʹ���ڴ棬��ʵ������ʹ�ô��̣�����α���ʹ��swap���̿ռ��أ�
Linux�����ڴ�ĵ�λ��ҳ(pages),һ���������4k��page��������ʹ�õĴ��ڴ�ʱ(>8G),������ô����ڴ�ͻ��ϵͳ��ɺܴ�ĸ������ټ���Ƶ����pagein/pageout�����Ϊϵͳ��ƿ����
1.hugepage����
2.ʵ������
1.hugepage����
hugepage����Linux2.6�ں˱�����ģ���Ҫ�ṩ4k��page�ͱȽϴ��page��ѡ�����Ƿ����ڴ�ʱ�����ȷ���”page table“��Ȼ��Linux��ͨ��“page table”��mapping��������ʵ�����ڴ棨ram+swap����Ϊ���������ܣ�Linux��cpu������̶���С��buffer������ΪTLB��TLB�б�����“page table”�IJ������ݣ���Ҳ��ѭ�ˣ������ݾ����ܵĿ���cpuԭ����TLB��ͨ��hugetlb��ָ��hugepage����Щ�������hugepage��Ϊ�ڴ��ļ�ϵͳhugetlbfs(����tmpfs)�ṩ������ʹ�á�
hugepage�ص�
Linuxϵͳ������hugepage�ͱ����䲢����������pagein/pageout��������Ϊ��Ԥ����ı�hugepage�����õȣ�
����Linux�ں˵İ汾��HW�ļܹ���hugepage�Ĵ�С��2M��256M���ȡ���Ϊ���ô�page������Ҳ����TLB
��page table�Ĺ���ѹ��
Ϊʲôʹ��hugepage
���ڴ��ڴ�(>8G),hugepage���������Linux�ϵ�Oracle�����Ƿdz��а�����
1)Larger Page Size and Less of Pages:������HugeTLB ������
2)No Page Table Lookups����Ϊhugepage�Dz�swappable�ģ����о�û��page table lookups��
3)No Swapping: ��Linux�£�hugepage�Dz�֧��swapping
4)No 'kswapd' Operations����Linux�½���“kswapd”�ǹ���swap�ģ�����Ǵ��ڴ棬��pages�������ͷdz�����“kswapd”�ͻᱻƵ���ĵ��ã��Ӷ���Ӱ�����ܡ�
2.ʵ������
A. Oracle10g����
ƽ̨��
hw��x86_64
os��RHEL5.4
kernel�� 2.6.18-164.el5
db��oracle10.2
1). ��root�û������ļ�“/etc/security/limits.conf”������memlock�����Ĵ�С��С�����ڴ棬���磺64GB���������£�
[root@skatedb ~]# vi /etc/security/limits.conf
##skate add
* soft memlock 60397977
* hard memlock 60397977
##skate add
2).��oracle���µ�¼�����memlock�������Ƿ���Ч
[oracle@skatedb ~]$ ulimit -l
60397977
3).ȷ�����е�oracle���ݿ�ʵ��������,����asmʵ����Ȼ�������½ű��������“vm.nr_hugepages"�Ĵ�С
------------------hugepages_settings.sh----------------------------
#!/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.
#
# 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. Before proceeding with the execution please 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}'`
# Initialize the counter
NUM_PG=0
# 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
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" ;;
*) echo "Unrecognized kernel version $KERN. Exiting." ;;
esac
# End
-----------------------hugepages_settings.sh-----------------------
Ҳ�����ֹ�����nr_hugepages>=SGA_Target/Hugepagesize
Ȼ���nr_hugepages��д���ļ�“/etc/sysctl.conf”��������������nr_hugepages=15000
[root@skatedb ~]# vi /etc/sysctl.conf
##skate add
vm.nr_hugepages=15000
##skate add
ʹ������Ч
[root@skatedb ~]# sysctl -p
4).ֹͣoracle���ݿ⣬reboot������
5).���hugepage�Ƿ���Ч
[root@skatedb ~]# grep HugePages /proc/meminfo
HugePages_Total: 15000
HugePages_Free: 4779
HugePages_Rsvd: 4676
���HugePages_Total=HugePages_Free��˵��HugePages����û�����á�
B. oracle11g����
ƽ̨��
hw��x86_64
os��RHEL5 (Taroon)
kernel�� 2.6.18-194.el5
db��oracle 11.2.0.2.0
oracle11g����������ͨ�����ò���MEMORY_TARGET/MEMORY_MAX_TARGET������AMM��oracle11g������SGA�ڴ�ķ��䷽ʽ����ͨ����/dev/shm�´����ļ����������ַ�ʽ�����sga�Dz�����hugepage�ģ�AMM��hugepage�Dz����ݵģ���Ϊ/dev/shm��tmpfs�ļ�ϵͳ����tmpfs�ļ�ϵͳ�Dz�֧��AMM��̬����sga��С�ģ�����Ҫ��ʹ��hugepage�����Ծ�Ҫ�ر�AMM���ԡ��������ȡ��Ϳ����ˡ�
ֹͣoracle11g��AMM
ֱ�Ӱ�MEMORY_MAX_TARGET��MEMORY_TARGET����Ϊ‘0’���ͱ����µĴ���
ORA-00843: Parameter not taking MEMORY_MAX_TARGET into account
ORA-00849: SGA_TARGET 35433480192 cannot be set to more than MEMORY_MAX_TARGET 0.
ORA-01078: failure in processing system parameters
���ֻ����MEMORY_TARGET=0��hugepage�Dz������õġ����Բ��ò������������������Ϳ��Թر�oracle11g��AMM�ˡ�����pfile.ora�ļ���Ȼ�����ļ���ɾ����������"MEMORY_TARGET/MEMORY_MAX_TARGET"��������Ϊ����ر�AMM�ĵط������˰��죬��ͨ����
ֹͣ��oracle11g��AMM���ڰ���oracle10g�����÷����Ϳ�������hugepage�ˡ�