linux huge模式设置,Linux 下 Hugepages的配置
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是不啟用hugepage的,AMM和hugepage是不兼容的,因為/dev/shm是tmpfs文件系統,而tmpfs文件系統是不支持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是不起作用的。所以采用不設置這兩個參數,就可以關閉oracle11g的AMM了。創建pfile.ora文件,然后在文件里刪除兩個參數"MEMORY_TARGET/MEMORY_MAX_TARGET"。就是因為這個關閉AMM的地方測試了半天,才通過。
停止了oracle11g的AMM后,在按著oracle10g的配置方法就可以啟動hugepage了。
總結
以上是生活随笔為你收集整理的linux huge模式设置,Linux 下 Hugepages的配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android开发实验-- 电话拨号器实
- 下一篇: linux ls按着文件数字大小排列