Oracle数据库配置大页

0    1534    10

Tags:

👉 本文共约4837个字,系统预计阅读时间或需19分钟。

简介

有关大页和透明大页的介绍:https://www.dbaup.com/linux-biaozhundayehetoumingdaye.html

在Linux中配置hugepage可以提高oracle的性能,减少oracle sga的页交换,类似于aix中的lagepage。
当你主机的物理内存为64G,设SGA>=32G时,建议开启大页。

要查看是否存在大页表的问题,可以使用如下的命令来检查页表的大小:

如果发现页表的大小不是几十兆,而是达到了1GB以上,就说明数据库存在此问题。基于共享内存的多进程架构的程序都会存在此问题。

Oracle 官方是推荐我们使用 Huge pages 的,它拥有以下的好处:

  • Larger Page Size and Less # of Pages: Default page size is 4K whereas the HugeTLB size is 2048K. That meansthe system would need to handle 512 times less pages.

  • Reduced Page Table Walking:Since a HugePage covers greater contiguous virtual address range than a regularsized page, a probability of getting a TLB hit per TLB entry with HugePages arehigher than with regular pages. This reduces the number of times page tablesare walked to obtain physical address from a virtual address.

  • Less Overhead for MemoryOperations: On virtual memory systems (any modern OS) each memory operation isactually two abstract memory operations. With HugePages, since there are lessnumber of pages to work on, the possible bottleneck on page table access isclearly avoided.

  • Less Memory Usage: From theOracle Database perspective, with HugePages, the Linux kernel will use lessmemory to create pagetables to maintain virtual to physical mappings for SGAaddress range, in comparison to regular size pages. This makes more memory tobe available for process-private computations or PGA usage.

  • No Swapping: We must avoidswapping to happen on Linux OS at all Document 1295478.1. HugePages are notswappable (whereas regular pages are). Therefore there is no page replacementmechanism overhead. HugePages are universally regarded as pinned.

  • No 'kswapd' Operations: kswapdwill get very busy if there is a very large area to be paged (i.e. 13 millionpage table entries for 50GB memory) and will use an incredible amount of CPUresource. When HugePages are used, kswapd is not involved in managing them. Seealso Document 361670.1

Huge pages 和 Oracle 11g新 特性 AMM ( Automatic Memory Management )是相互冲突的,但是 ASMM ( Automatic Shared Memory Management )仍然可以继续使用。

Oracle 官方推荐我们使用 标准大页(Huge pages ),但是却建议我们关闭 透明大页(Transparent Huge pages) ,因为透明大页存在一些问题:

  1. 在 RAC 环境下 透明大页( TransparentHugePages )会导致异常节点重启,和性能问题;
  2. 在单机环境中,透明大页( TransparentHugePages ) 也会导致一些异常的性能问题;

    如何关闭透明大页请参考:https://www.dbaup.com/linux-biaozhundayehetoumingdaye.html

如何配置开启大页

参考:HugePages on Oracle Linux 64-bit (Doc ID 361468.1)

  1. 在 /etc/security/limits.conf 加入以下参数,单位为KB,值比内存稍微少一点即可,例如内存为16GB,那么可以如下设置:

memlock 参数的值只需略小于内存的值即可,但是必须大于sga_max_size的值。

也可以直接配置-1,表示不限制:

注意:这里需要仔细查看文件/etc/security/limits.conf的内容,若文件有如下内容,则需要手动注释,或删除如下内容:

  1. 重新以oracle用户登录服务器验证设置

  1. 在 Oracle 11g 中禁用 AutomaticMemory Management (AMM) 特性,即 设置MEMORY_TARGET和MEMORY_MAX_TARGET 值为0 。因为AMM和大页特性不兼容。注意:若有ASM实例,那么ASM实例也应该使用ASMM。

    在Linux操作系统推荐配置HugePages,以至于ASM和数据库实例的SGA都能使用HugePage来提高性能。ASM实例的SGA同样有必要使用HugePage来提高性能。

这里的环境并没有启用 AMM 特性,如果启用了AMM,那么请使用以下语句关闭,并从spfile中删除该参数:

重启实例后生效。

Note: Starting in 11.2.0.3, AMM is no longer configured by default if DBCA detects that the machine has more than 4GB of RAM. See Document 1453227.1 for details.

  1. 确认所有需要使用 Hugepage 的数据库实例都是开启的 ( 包括 ASM 实例 ) ,然后运行脚本 hugepages_settings.sh(具体脚本参考文档 Document 401749.1)来计算*vm.nr_hugepages*kernel的值。

实际上hugepages与参数sga_max_size有关,比sga_max_size的值稍微大一点点(比SGA_MAX_SIZE最少要多加一页,2M的页不要分配超过sga_max_size太多,会造成内存的浪费)。

本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信dbaup66,谢谢!
AiDBA后续精彩内容已被站长无情隐藏,请输入验证码解锁本文!
验证码:
获取验证码: 请先关注本站微信公众号,然后回复“验证码”,获取验证码。在微信里搜索“AiDBA”或者“dbaup6”或者微信扫描右侧二维码都可以关注本站微信公众号。

标签:

Avatar photo

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复