如何给 linux 环境下的 oracle 数据库服务器配置 HugePages。oracle优化
金蝶云社区-天冥异
天冥异
9人赞赏了该文章 558次浏览 未经作者许可,禁止转载编辑于2018年06月15日 09:29:59

 

本文解释,如何给 linux 环境下的 oracle 数据库服务器配置 HugePages。

要求:linux 5.6 及以上。

Hugepages -> 大页,  linux 环境,大页的尺寸一般为2M.

为方便说明:文章中假设,服务器的物理内存为:64G.

 

1   以 root 身份,编辑文件 /etc/security/limits.conf, 增加内容:

 

    Oracle  soft   memlock    60397977  à 单位 KB

Oracle  hard  memlock    60397977

 

此参数值,比物理内存(64G)稍小。

若是oracle linux操作系统,该参数可能已经在文件中自动设置好,无需改动。

 

2  以 oracle 身份登录服务器,执行命令: $ ulimit –l,应该出现以下结果:

 

   $ ulimit -l

60397977

 

3  由于 HugePages 与 AMM 不兼容,故,需要把 memory_max_target, memory_target 初始化为0,同时设置需要的 sga 值,此处设置 sga值,为物理内存的一半。

 

   alter system set memory_max_target=0 scope=spfile sid='*';

alter system set memory_target=0 scope=spfile sid='*';

alter system set sga_max_size=32g scope=spfile sid=’*’;

 

4  重启数据库实例 Startup nomount;

5  在操作系统下运行脚本: hugepages_setting.sh,以计算操作系统参数值 vm.nr_hugepages

 

$ ./hugepages_settings.sh

...

Recommended setting: vm.nr_hugepages = 16386

$

 

6  以 root 身份,编辑/etc/sysctl.conf 文件,在该文件尾,添加:

 vm.nr_hugepages = 16386

 

7  以 root 身份,执行命令: 以便让该参数生效,

   # Sysctl -p

   该命令会输出一系列的参数值,若见到vm.nr_hugepages = 16386,说明参数开始还生效,

 

8  关闭,重启实例,同时查看数据库的警告日志,若出现下面红色部分的信息,说明 HugePages 设置成功,否则,配置失败,

 

 

 

 

Starting ORACLE instance (normal)

****************** Large Pages Information *****************

 

Total Shared Global Region in Large Pages = 5122 MB (100%)

 

Large Pages used by this instance: 2561 (5122 MB)

Large Pages unused system wide = 10 (20 MB) (alloc incr 16 MB)

Large Pages configured system wide = 39436 (77 GB)

Large Page size = 2048 KB

***********************************************************

 

9  数据库运行一段时间后,可以查看到大页的使用情况。

 

$grep Huge /proc/meminfo

HugePages_Total:   39436

HugePages_Free:     2766

HugePages_Rsvd:     2756

HugePages_Surp:        0

Hugepagesize:       2048 kB

 

HugePages_Total:   大页总数量,即:vm.nr_hugepages 的值

HugePages_Free:   从来没有被使用过的大页的数目,HugePages_Total - HugePages_Free ,已经分配给 sga 的内存值。

HugePages_Rsvd:   保留大页数,

HugePages_Surp:   剩余大页数,

Hugepagesize:     大页的尺寸。

 

HugePages_Total is the size of the pool of huge pages.

HugePages_Free  is the number of huge pages in the pool that are not yet

                allocated.

HugePages_Rsvd  is short for "reserved," and is the number of huge pages for

                which a commitment to allocate from the pool has been made,

                but no allocation has yet been made.  Reserved huge pages

                guarantee that an application will be able to allocate a

                huge page from the pool of huge pages at fault time.

HugePages_Surp  is short for "surplus," and is the number of huge pages in

                the pool above the value in /proc/sys/vm/nr_hugepages. The

                maximum number of surplus huge pages is controlled by

                /proc/sys/vm/nr_overcommit_hugepages.

 

 

 

10  使用HugePages的注意事项

  下面的三种情形应当重新配置HugePages 参数

      a、物理内存的增减或减少。

    b、在当前服务器上新增或移出Instance。

      c、Instance的SGA大小增加或减少。

  如果未及时调整HugePages,可能会引发下面的问题:

      a、数据库性能低下。

      b、出现内存不足或者过度使用交换空间。

    c、数据库实例不能被启动。

      d、关键性系统服务故障。

 

 


赞 9