ITPub博客

首页 > 数据库 > 国内数据库 > racle Database instance is up 开启大页特性Oracle数据库在linux平台上开启大页特性

racle Database instance is up 开启大页特性Oracle数据库在linux平台上开启大页特性

原创 国内数据库 作者:businessqaz 时间:2021-03-01 21:05:10 0 删除 编辑

Oracle数据库在linux平台上

1、 检查memory_target , memory_max_target ,如果不为 0 ,将其更改为 0.

SQL> show parameter memory_target

 

NAME      TYPE  VALUE

------------------------------------ ----------- ------------------------------

memory_target      big integer 0

SQL> show parameter memory_max_target

 

NAME      TYPE  VALUE

------------------------------------ ----------- ------------------------------

memory_max_target      big integer 0

SQL>

2、计算hugepages 的值(脚本内容见最后)

[root@gxjzfpdb01 soft]# ./hugepages_settings.sh 

 

This script is provided by Doc ID 401749.1 from My Oracle Support

() 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...

 

Recommended setting: vm.nr_hugepages = 19012

  得出大页的大小为 19012 页(注:一页为 2M ,这个值不可改, 19012*2M=38024M ),实际上 hugepages 与参数 sga_max_size 有关,比 sga_max_size 的值稍微大一点点(比 SGA_MAX_SIZE 最少要多加一页, 2M 的页不要分配超过 sga_max_size 太多,会造成内存的浪费):

SQL> show parameter sga

 

NAME      TYPE  VALUE

------------------------------------ ----------- ------------------------------

lock_sga      boolean  FALSE

pre_page_sga      boolean  FALSE

sga_max_size      big integer 38016M

sga_target      big integer 38016M

3 、设置 hugepages ,在内核参数中添加一行 ,vi /etc/sysctl.conf

vm.nr_hugepages = 19012

4、 修改内核参数立即生效
[root@gxjzfpdb01 ~]# sysctl -p

5 、 设定/etc/security/limits.conf 文件,以 K 为单位,必须大于 sga_max_size, 这里设定为89128960

[root@gxjzfpdb01 ~]# vi /etc/security/limits.conf

*   soft   memlock   89128960 

*   hard   memlock   89128960

6 、 检查limits 是否正确
[root@gxjzfpdb01 ~]# su - oracle
[oracle@gxjzfpdb02 ~]$ ulimit -l

89128960

7、 重启数据库,检查大页是否被使用。

SQL> shu immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

[oracle@gxjzfpdb02 ~]$ exit

logout

[root@gxjzfpdb02 ~]# su - oracle

[oracle@gxjzfpdb02 ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Mon Jun 6 11:40:56 2016

 

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

SQL> startup

ORACLE instance started.

 

Total System Global Area 3.9685E+10 bytes

Fixed Size     2261728 bytes

Variable Size  6576672032 bytes

Database Buffers  3.3018E+10 bytes

Redo Buffers    88203264 bytes

Database mounted.

Database opened.

SQL>

检查大页特性是否使用:

[root@gxjzfpdb02 soft]# cat /proc/meminfo | grep Hu

AnonHugePages:    342016 kB

HugePages_Total:   19012

HugePages_Free:    15157

HugePages_Rsvd:    15154

HugePages_Surp:        0

Hugepagesize:       2048 kB

[root@gxjzfpdb02 soft]#

注:
HugePages_Total:  19012--- 总共 1028 页
HugePages_Free:    15157--- 空闲15157 页,即当前大页被使用了19012-15157=3855 页,即被用了3855*2M=7710M ,小于 sga_target 。
HugePages_Rsvd:    15154--- 操作系统承诺给 Oracle 预留15154 页,即15154*2M=30308M ( 30308+7710==SGA_MAX_SIZE )
Hugepagesize:     2048 kB -- 每页是 2M ,不可修改

可以看到,大页已被使用,至此,大页特性已经开启。

附脚本内容:
#!/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 
#


# Welcome text
echo "
This script is provided by Doc ID 401749.1 from My Oracle Support 
() 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


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69995495/viewspace-2760401/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2021-03-01

  • 博文量
    27
  • 访问量
    17166