8.12.4.2 Enabling Large Page Support

Some hardware/operating system architectures support memory pages greater than the default (usually 4KB). The actual implementation of this support depends on the underlying hardware and operating system. Applications that perform a lot of memory accesses may obtain performance improvements by using large pages due to reduced Translation Lookaside Buffer (TLB) misses.

In MySQL, large pages can be used by InnoDB, to allocate memory for its buffer pool and additional memory pool.

Standard use of large pages in MySQL attempts to use the largest size supported, up to 4MB. Under Solaris, a “super large pages” feature enables uses of pages up to 256MB. This feature is available for recent SPARC platforms. It can be enabled or disabled by using the --super-large-pages or --skip-super-large-pages option.

MySQL also supports the Linux implementation of large page support (which is called HugeTLB in Linux).

Before large pages can be used on Linux, the kernel must be enabled to support them and it is necessary to configure the HugeTLB memory pool. For reference, the HugeTBL API is documented in the Documentation/vm/hugetlbpage.txt file of your Linux sources.

The kernel for some recent systems such as Red Hat Enterprise Linux appear to have the large pages feature enabled by default. To check whether this is true for your kernel, use the following command and look for output lines containing “huge”:

  1. shell> cat /proc/meminfo | grep -i huge
  2. HugePages_Total: 0
  3. HugePages_Free: 0
  4. HugePages_Rsvd: 0
  5. HugePages_Surp: 0
  6. Hugepagesize: 4096 kB

The nonempty command output indicates that large page support is present, but the zero values indicate that no pages are configured for use.

If your kernel needs to be reconfigured to support large pages, consult the hugetlbpage.txt file for instructions.

Assuming that your Linux kernel has large page support enabled, configure it for use by MySQL using the following commands. Normally, you put these in an rc file or equivalent startup file that is executed during the system boot sequence, so that the commands execute each time the system starts. The commands should execute early in the boot sequence, before the MySQL server starts. Be sure to change the allocation numbers and the group number as appropriate for your system.

  1. # Set the number of pages to be used.
  2. # Each page is normally 2MB, so a value of 20 = 40MB.
  3. # This command actually allocates memory, so this much
  4. # memory must be available.
  5. echo 20 > /proc/sys/vm/nr_hugepages
  6. # Set the group number that is permitted to access this
  7. # memory (102 in this case). The mysql user must be a
  8. # member of this group.
  9. echo 102 > /proc/sys/vm/hugetlb_shm_group
  10. # Increase the amount of shmem permitted per segment
  11. # (12G in this case).
  12. echo 1560281088 > /proc/sys/kernel/shmmax
  13. # Increase total amount of shared memory. The value
  14. # is the number of pages. At 4KB/page, 4194304 = 16GB.
  15. echo 4194304 > /proc/sys/kernel/shmall

For MySQL usage, you normally want the value of shmmax to be close to the value of shmall.

To verify the large page configuration, check /proc/meminfo again as described previously. Now you should see some nonzero values:

  1. shell> cat /proc/meminfo | grep -i huge
  2. HugePages_Total: 20
  3. HugePages_Free: 20
  4. HugePages_Rsvd: 0
  5. HugePages_Surp: 0
  6. Hugepagesize: 4096 kB

The final step to make use of the hugetlb_shm_group is to give the mysql user an “unlimited” value for the memlock limit. This can be done either by editing /etc/security/limits.conf or by adding the following command to your mysqld_safe script:

  1. ulimit -l unlimited

Adding the ulimit command to mysqld_safe causes the root user to set the memlock limit to unlimited before switching to the mysqluser. (This assumes that mysqld_safe is started by root.)

Large page support in MySQL is disabled by default. To enable it, start the server with the --large-pages option. For example, you can use the following lines in the server my.cnf file:

  1. [mysqld]
  2. large-pages

With this option, InnoDB uses large pages automatically for its buffer pool and additional memory pool. If InnoDB cannot do this, it falls back to use of traditional memory and writes a warning to the error log: Warning: Using conventional memory pool

To verify that large pages are being used, check /proc/meminfo again:

  1. shell> cat /proc/meminfo | grep -i huge
  2. HugePages_Total: 20
  3. HugePages_Free: 20
  4. HugePages_Rsvd: 2
  5. HugePages_Surp: 0
  6. Hugepagesize: 4096 kB

为MySQ启用HugePage的更多相关文章

  1. 【云和恩墨】性能优化:Linux环境下合理配置大内存页(HugePage)

    原创 2016-09-12 熊军 [云和恩墨]性能优化:Linux环境下合理配置大内存页(HugePage)   熊军(老熊) 云和恩墨西区总经理 Oracle ACED,ACOUG核心会员 PC S ...

  2. 在Linux 64位系统下使用hugepage

    首先,为什么要介绍/使用HugePage? 在步入正题之前,先讲一个非常普遍的数据库性能问题. 众所周知,Oracle数据库使用共享内存(SGA)来管理可以共享的一些资源;比如shared pool中 ...

  3. TNS-12518 & Linux Error:32:Broken pipe

    最近一周,有一台ORACLE数据库服务器的监听服务在凌晨2点过几分的时间点突然崩溃,以前从没有出现过此类情况,但是最近一周出现了两次这种情况,检查时发现了如下一些信息: $ lsnrctl servi ...

  4. 【故障•监听】TNS-12518、TNS-00517和 Linux Error:32:Broken pipe

    [故障|监听]TNS-12518.TNS-00517和 Linux Error:32:Broken pipe 1.1  BLOG文档结构图 1.2  前言部分 1.2.1  导读和注意事项 各位技术爱 ...

  5. Linux传统Huge Pages与Transparent Huge Pages再次学习总结

      Linux下的大页分为两种类型:标准大页(Huge Pages)和透明大页(Transparent Huge Pages).Huge Pages有时候也翻译成大页/标准大页/传统大页,它们都是Hu ...

  6. 转://Linux大内存页Oracle数据库优化

    PC Server发展到今天,在性能方面有着长足的进步.64位的CPU在数年前都已经进入到寻常的家用PC之中,更别说是更高端的PC Server:在Intel和AMD两大处理器巨头的努力下,x86 C ...

  7. Oracle测试环境参数调整.

    测试环境上面Oracle数据库性能参数设置 1. 关闭回收站 alter system set recyclebin=off 2. 修改redo日志的大小 11g的默认大小是50m 如果redo fi ...

  8. Oracle内存管理方式由amm切换为asmm

    (一)ASMM和AMM 在Oracle 10g时,Orale推出ASMM(Automatic Shared Memory Managed),实现了SGA和PGA各自内部的自调节.在Oracle 11g ...

  9. OpenStack 高性能虚拟机之大页内存

    目录 文章目录 目录 前文列表 虚拟存储器系统 页式虚拟存储器 大页内存 Linux 的大页内存 大页的实现原理 大页内存配置 透明巨型页 THP 大页面对内存的影响 Nova 虚拟机的大页内存设置 ...

随机推荐

  1. 详解C#委托和事件(二)

    一.当我们使用关键字delegate声明一个自定义委托类型时,实际上是声明了一个该名称的类类型,继承自抽象类System.MulticastDelegate,还包含实例方法Invoke.BeginIn ...

  2. INTEST/EXTEST SCAN

    INTEST scan指的是对IP 内部的scan cell的扫描测试,针对IP内部的flip-flop进行shift/capture的操作.和INTEST SCAN 对应的就是EXTEST SCAN ...

  3. tcp/ip通信中ip头部结构iph->check校验计算

    通过raw socket修改通信数据后,可通过该函数重新校验计算iph->check值 在http://www.cnblogs.com/dpf-10/p/7899237.html查看实际调用 s ...

  4. Solr 配置中文分词器 IK

    1. 下载或者编译 IK 分词器的 jar 包文件,然后放入 ...\apache-tomcat-8.5.16\webapps\solr\WEB-INF\lib\ 这个 lib 文件目录下: IK 分 ...

  5. SSM整合Shiro 身份验证及密码加密简单实现

    1.导入maven的相关依赖 <!-- shiro --> <dependency> <groupId>org.apache.shiro</groupId&g ...

  6. C#操作MongoDB入门

    1.MongoDB安装及配置 (1)下载:   mongodb官网 https://www.mongodb.com/download-center      进入官网下载页,你会发现版本都是windo ...

  7. [日常] Go语言圣经-匿名函数习题2

    练习5.13: 修改crawl,使其能保存发现的页面,必要时,可以创建目录来保存这些页面.只保存来自原始域名下的页面.假设初始页面在golang.org下,就不 要保存vimeo.com下的页面. p ...

  8. [日常] Go语言圣经-Slice切片习题

    1.Slice(切片)代表变长的序列,序列中每个元素都有相同的类型,一个slice类型一般写作[]T,其中T代表slice中元素的类型:slice的语法和数组很像,只是没有固定长度而已,slice的底 ...

  9. Java基础——JSP(二)

    一.JSP隐式对象概述 为了简化jsp表达式和脚本片断代码的编写,JSP一共提供了9个预先定义的变量,这些变量也称为隐式对象或内置对象. 在 jsp生成的Servlet源码中,有如下声明: publi ...

  10. static ,final 、abstract的作用,以及它们的联系和区别

    static可以修饰变量,修饰的变量直接属于某各类,不局限于某个方法,无法在成员方法中修饰变量,也不可以在静态方法中修饰变量.被static修饰的方法属于静态方法(类方法),与对象无关,与类有关.fi ...