配置Linux服务器 hugepages

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:904

[font=Arial, "] [backcolor=rgb(152, 222, 222)][size=20px]1 配置limits.conf

[oracle@xkan ~]$ free -m total used free shared buffers cachedMem: 5709 2386 3322 1 25 366-/+ buffers/cache: 1994 3715Swap: 5999 0 5999
[font=Arial, "] 根据内存大小,我们配置5G到memlock

[root@xkan ~]# grep memlock /etc/security/limits.conf # - memlock - max locked-in-memory address space (KB)* soft memlock 5242880* hard memlock 5242880
[font=Arial, "] 参数生效需要重启

[root@xkan ~]# ulimit -l5242880
[font=Arial, "] [backcolor=rgb(152, 222, 222)][size=20px]2 查看AMM是否关闭

[oracle@xkan ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 14 19:47:34 2017Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> show parameter sgaNAME TYPE VALUE------------------------------------ ----------- ------------------------------lock_sga boolean FALSEpre_page_sga boolean FALSEsga_max_size big integer 1728Msga_target big integer 1728MSQL> show parameter pgaNAME TYPE VALUE------------------------------------ ----------- ------------------------------pga_aggregate_target big integer 571MSQL> show parameter memoryNAME TYPE VALUE------------------------------------ ----------- ------------------------------hi_shared_memory_address integer 0memory_max_target big integer 0memory_target big integer 0shared_memory_address integer 0

[font=Arial, "] [backcolor=rgb(152, 222, 222)][size=20px]3 使用 hugepages_settings.sh 计算 vm.nr_hugepages
[font=Arial, "] 需要在所有oracle实例包括ASM实例都启动的情况下进行

[oracle@xkan ~]$ vim hugepages_settings.sh[oracle@xkan ~]$ ./hugepages_settings.sh-bash: ./hugepages_settings.sh: Permission denied[oracle@xkan ~]$ chmod 755 hugepages_settings.sh[oracle@xkan ~]$ ./hugepages_settings.shThis script is provided by Doc ID 401749.1 from My Oracle Support(http://support.oracle.com) where it is intended to compute values forthe recommended HugePages/HugeTLB configuration for the current sharedmemory 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 -mPress Enter to proceed...Recommended setting: vm.nr_hugepages = 868
[font=Arial, "]
hugapages_settings.sh
[oracle@xkan ~]$ cat 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 textecho "This script is provided by Doc ID 401749.1 from My Oracle Support(http://support.oracle.com) where it is intended to compute values forthe recommended HugePages/HugeTLB configuration for the current sharedmemory 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 -mPress Enter to proceed..."read# Check for the kernel versionKERN=`uname -r | awk -F. '{ printf("%d.%d/n",$1,$2); }'`# Find out the HugePage sizeHPG_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 1fi# Initialize the counterNUM_PG=0# Cumulative number of pages required to handle the running shared memory segmentsfor 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` fidoneRES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`# An SGA less than 100MB does not make sense# Bail out if that is the caseif [ $RES_BYTES -lt 100000000 ]; then echo "***********" echo "** ERROR **" echo "***********" echo "Sorry! There are not enough total of shared memory segments allocated forHugePages configuration. HugePages can only be used for shared memory segmentsthat you can list by command: # ipcs -mof 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 1fi# Finish with resultscase $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

[font=Arial, "] [backcolor=rgb(152, 222, 222)][size=20px]4 配置 /etc/sysctl.conf 文件

[root@xkan ~]# vim /etc/sysctl.conf[root@xkan ~]# grep vm.nr_hugepages /etc/sysctl.confvm.nr_hugepages=868
[font=Arial, "] [backcolor=rgb(152, 222, 222)][size=20px]5 重启实例和服务器,检查 hugepage 配置情况

[root@xkan ~]# su - oracle[oracle@xkan ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 14 20:12:59 2017Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options[oracle@xkan ~]$ lsnrctl stopLSNRCTL for Linux: Version 11.2.0.4.0 - Production on 14-JUN-2017 20:13:24Copyright (c) 1991, 2013, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))The command completed successfully[oracle@xkan ~]$ exitlogout[root@xkan ~]# reboot[root@xkan ~]# grep HugePages /proc/meminfoAnonHugePages: 8192 kBHugePages_Total: 868HugePages_Free: 868HugePages_Rsvd: 0HugePages_Surp: 0[root@xkan ~]# su - oracle[oracle@xkan ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 14 20:15:30 2017Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to an idle instance.SQL> startupORACLE instance started.Total System Global Area 1803841536 bytesFixed Size 2254144 bytesVariable Size 486542016 bytesDatabase Buffers 1308622848 bytesRedo Buffers 6422528 bytesDatabase mounted.Database opened.SQL> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options[oracle@xkan ~]$ grep HugePages /proc/meminfoAnonHugePages: 14336 kBHugePages_Total: 868HugePages_Free: 671HugePages_Rsvd: 668HugePages_Surp: 0[oracle@xkan ~]$

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】