前言:


对于有Oracle运维经验的童鞋来说,如果服务器内存很大,一般都会设置HugePages,是因为如下原因:
<div style="background-color: inherit;">
    对于&nbsp;Linux&nbsp;操作系统,通过&nbsp;Linux&nbsp;kswapd&nbsp;进程和页表内存结构(针对系统中存在的每个进程包含一条记录)实现内存管理。&nbsp;
</div>

<div style="background-color: inherit;">
    linux的内存管理采取的是分页存取机制,为了保证物理内存能得到充分的利用,
</div>

<div style="background-color: inherit;">
    内核会按照LRU算法在适当的时候将物理内存中不经常使用的内存页自动交换到虚拟内存中,
</div>

<div style="background-color: inherit;">
    而将经常使用的信息保留到物理内存。通常情况下,Linux默认情况下每页是4K,这就意味着如果物理内存很大,则映射表的条目将会非常多,
</div>

<div style="background-color: inherit;">
    会影响CPU的检索效率。而且也浪费内存。因为内存大小是固定的,为了减少映射表的条目,可采取的办法只有增加页的尺寸。
</div>

<div style="background-color: inherit;">
    因此Hugepage便因此而来。也就是打破传统的小页面的内存管理方式,使用大页面2m,4m,16m,但是Linux系统的大页默认就是2M
</div>

<div style="background-color: inherit;">
    如此一来映射条目则明显减少。如果系统有大量的物理内存(大于64G),建议使用Hugepage。
</div>

<div style="background-color: inherit;">
    注意事项
</div>

<div style="background-color: inherit;">
    &nbsp;1、HugePage使用的是共享内存,在操作系统启动期间被动态分配并被保留,因为他们不会被置换。
</div>

<div style="background-color: inherit;">
    &nbsp;2、由于不会被置换的特点,在使用hugepage的内存不能被其他的进程使用。所以要合理设置该值,避免造成内存浪费。
</div>

<div style="background-color: inherit;">
    &nbsp;3、如果增加HugePage或添加物理内存或者是当前服务器增加了新的instance以及SGA设置发生变化,应该重新设置所需的HugePage。
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    辣么,MySQL也是支持滴,那么下面开始讲讲怎么设置大页内存
</div>

<div style="background-color: inherit;">
    1.首先来看看共享段内存,
</div>

<div style="background-color: inherit;">
    ###centos6的默认共享段内存大小是64G,如果你服务器内存没有超过128G,可以不用修改
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    #&nbsp;Controls&nbsp;the&nbsp;maximum&nbsp;shared&nbsp;segment&nbsp;size,&nbsp;in&nbsp;bytes
</div>

<div style="background-color: inherit;">
    kernel.shmmax&nbsp;=&nbsp;68719476736&nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    #&nbsp;Controls&nbsp;the&nbsp;maximum&nbsp;number&nbsp;of&nbsp;shared&nbsp;memory&nbsp;segments,&nbsp;in&nbsp;pages
</div>

<div style="background-color: inherit;">
    kernel.shmall&nbsp;=&nbsp;4294967296
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    ###先透露一下,使用大页内存的和没有使用大页内存的PageTables&nbsp;
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@crmdbL-172</font>](mailto:root@crmdbL-172)&nbsp;~]#&nbsp;free&nbsp;-m
</div>

<div style="background-color: inherit;">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;used&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shared&nbsp;&nbsp;&nbsp;&nbsp;buffers&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cached
</div>

<div style="background-color: inherit;">
    Mem:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;32058&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;29144&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2913&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;20&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;11526
</div>

<div style="background-color: inherit;">
    -/+&nbsp;buffers/cache:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;17597&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;14460
</div>

<div style="background-color: inherit;">
    Swap:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8191&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8188
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@crmdbL-172</font>](mailto:root@crmdbL-172)&nbsp;~]#&nbsp;
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@crmdbL-172</font>](mailto:root@crmdbL-172)&nbsp;~]#&nbsp;cat&nbsp;/proc/meminfo&nbsp;|&nbsp;grep&nbsp;PageTables&nbsp;
</div>

<div style="background-color: inherit;">
    PageTables:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;44808&nbsp;kB
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@crmdbL-172</font>](mailto:root@crmdbL-172)&nbsp;~]#&nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@node-207</font>](mailto:root@node-207)&nbsp;~]#&nbsp;free&nbsp;-m
</div>

<div style="background-color: inherit;">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;used&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shared&nbsp;&nbsp;&nbsp;&nbsp;buffers&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cached
</div>

<div style="background-color: inherit;">
    Mem:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;32095&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;28501&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3593&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;21&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;9233
</div>

<div style="background-color: inherit;">
    -/+&nbsp;buffers/cache:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;19246&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;12848
</div>

<div style="background-color: inherit;">
    Swap:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8095&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8095
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@node-207</font>](mailto:root@node-207)&nbsp;~]#&nbsp;
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@node-207</font>](mailto:root@node-207)&nbsp;~]#&nbsp;cat&nbsp;/proc/meminfo&nbsp;|&nbsp;grep&nbsp;PageTables&nbsp;
</div>

<div style="background-color: inherit;">
    PageTables:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5372&nbsp;kB
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@node-207</font>](mailto:root@node-207)&nbsp;~]#&nbsp;
</div>

<div style="background-color: inherit;">
    差距呢44808-5372=39436
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    2.设置MySQL使用大页内存
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    ########下面开始设置使用大页内存
</div>

<div style="background-color: inherit;">
    innodb_buffer_pool_size&nbsp;=&nbsp;16384M
</div>

<div style="background-color: inherit;">
    innodb_additional_mem_pool_size&nbsp;=&nbsp;16M
</div>

<div style="background-color: inherit;">
    16384M+16M/2=8200
</div>

<div style="background-color: inherit;">
    根据以往对ORACLE设置大页的经验,大页内存要大于这个内存,所以我设置了8211个大页
</div>

<div style="background-color: inherit;">
    vim&nbsp;/etc/sysctl.conf&nbsp;
</div>

<div style="background-color: inherit;">
    ####&nbsp;HugePages&nbsp;大小&nbsp;
</div>

<div style="background-color: inherit;">
    vm.nr_hugepages=8211
</div>

<div style="background-color: inherit;">
    ###使用大页内存的用户ID
</div>

<div style="background-color: inherit;">
    vm.hugetlb_shm_group=3306&nbsp;(id&nbsp;mysql得到的结果)
</div>

<div style="background-color: inherit;">
    设置当前系统生效,只要刷新一下就行了
</div>

<div style="background-color: inherit;">
    sysctl&nbsp;-p
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    vim&nbsp;/etc/security/limits.conf&nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;soft&nbsp;nofile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;65535
</div>

<div style="background-color: inherit;">
    &nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;soft&nbsp;nproc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;65535
</div>

<div style="background-color: inherit;">
    &nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hard&nbsp;nofile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;65535
</div>

<div style="background-color: inherit;">
    &nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hard&nbsp;nproc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;65535
</div>

<div style="background-color: inherit;">
    #*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;soft&nbsp;&nbsp;&nbsp;&nbsp;core&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0
</div>

<div style="background-color: inherit;">
    #*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hard&nbsp;&nbsp;&nbsp;&nbsp;rss&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10000
</div>

<div style="background-color: inherit;">
    #@student&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hard&nbsp;&nbsp;&nbsp;&nbsp;nproc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;20
</div>

<div style="background-color: inherit;">
    #@faculty&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;soft&nbsp;&nbsp;&nbsp;&nbsp;nproc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;20
</div>

<div style="background-color: inherit;">
    #@faculty&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hard&nbsp;&nbsp;&nbsp;&nbsp;nproc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;50
</div>

<div style="background-color: inherit;">
    #ftp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hard&nbsp;&nbsp;&nbsp;&nbsp;nproc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0
</div>

<div style="background-color: inherit;">
    #@student&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maxlogins&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4
</div>

<div style="background-color: inherit;">
    ###设置mysql&nbsp;使用&nbsp;HugePages&nbsp;
</div>

<div style="background-color: inherit;">
    @mysql&nbsp;soft&nbsp;memlock&nbsp;unlimited
</div>

<div style="background-color: inherit;">
    @mysql&nbsp;hard&nbsp;memlock&nbsp;unlimited
</div>

<div style="background-color: inherit;">
    oracle使用大页也是这样设置
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    重启MySQL,查看错误日志,
</div>

<div style="background-color: inherit;">
    16:37:43&nbsp;mysqld_safe&nbsp;mysqld&nbsp;from&nbsp;pid&nbsp;file&nbsp;/data/3306/tmp/mysql.pid&nbsp;ended
</div>

<div style="background-color: inherit;">
    16:37:44&nbsp;mysqld_safe&nbsp;Starting&nbsp;mysqld&nbsp;daemon&nbsp;with&nbsp;databases&nbsp;from&nbsp;/data/3306/data
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:37:45&nbsp;0&nbsp;[Note]&nbsp;/opt/app/mysql/bin/mysqld&nbsp;(mysqld&nbsp;5.6.24-log)&nbsp;starting&nbsp;as&nbsp;process&nbsp;13420&nbsp;...
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:37:45&nbsp;13420&nbsp;[Note]&nbsp;Plugin&nbsp;&#39;FEDERATED&#39;&nbsp;is&nbsp;disabled.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:37:45&nbsp;7f56f311d740&nbsp;InnoDB:&nbsp;Warning:&nbsp;Using&nbsp;innodb_additional_mem_pool_size&nbsp;is&nbsp;DEPRECATED.&nbsp;This&nbsp;option&nbsp;may&nbsp;be&nbsp;removed&nbsp;in&nbsp;future&nbsp;releases,&nbsp;together&nbsp;with&nbsp;the&nbsp;option&nbsp;innodb_use_sys_malloc&nbsp;and&nbsp;with&nbsp;the&nbsp;InnoDB&#39;s&nbsp;internal&nbsp;memory&nbsp;allocator.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:37:45&nbsp;13420&nbsp;[Note]&nbsp;InnoDB:&nbsp;Using&nbsp;atomics&nbsp;to&nbsp;ref&nbsp;count&nbsp;buffer&nbsp;pool&nbsp;pages
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:37:45&nbsp;13420&nbsp;[Note]&nbsp;InnoDB:&nbsp;The&nbsp;InnoDB&nbsp;memory&nbsp;heap&nbsp;is&nbsp;disabled
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:37:45&nbsp;13420&nbsp;[Note]&nbsp;InnoDB:&nbsp;Mutexes&nbsp;and&nbsp;rw_locks&nbsp;use&nbsp;GCC&nbsp;atomic&nbsp;builtins
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:37:45&nbsp;13420&nbsp;[Note]&nbsp;InnoDB:&nbsp;Memory&nbsp;barrier&nbsp;is&nbsp;not&nbsp;used
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:37:45&nbsp;13420&nbsp;[Note]&nbsp;InnoDB:&nbsp;Compressed&nbsp;tables&nbsp;use&nbsp;zlib&nbsp;1.2.3
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:37:45&nbsp;13420&nbsp;[Note]&nbsp;InnoDB:&nbsp;Using&nbsp;Linux&nbsp;native&nbsp;AIO
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:37:45&nbsp;13420&nbsp;[Note]&nbsp;InnoDB:&nbsp;Using&nbsp;CPU&nbsp;crc32&nbsp;instructions
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:37:45&nbsp;13420&nbsp;[Note]&nbsp;InnoDB:&nbsp;Initializing&nbsp;buffer&nbsp;pool,&nbsp;size&nbsp;=&nbsp;16.0G
</div>

<div style="background-color: inherit;">
    InnoDB:&nbsp;HugeTLB:&nbsp;Warning:&nbsp;Failed&nbsp;to&nbsp;allocate&nbsp;2197815296&nbsp;bytes.&nbsp;errno&nbsp;12
</div>

<div style="background-color: inherit;">
    InnoDB&nbsp;HugeTLB:&nbsp;Warning:&nbsp;Using&nbsp;conventional&nbsp;memory&nbsp;pool
</div>

<div style="background-color: inherit;">
    居然两个警告
</div>

<div style="background-color: inherit;">
    InnoDB:&nbsp;HugeTLB:&nbsp;Warning:&nbsp;Failed&nbsp;to&nbsp;allocate&nbsp;2197815296&nbsp;bytes.&nbsp;errno&nbsp;12
</div>

<div style="background-color: inherit;">
    InnoDB&nbsp;HugeTLB:&nbsp;Warning:&nbsp;Using&nbsp;conventional&nbsp;memory&nbsp;pool&nbsp;&nbsp;####using&nbsp;conventional&nbsp;memory&nbsp;pool
</div>

<div style="background-color: inherit;">
    因为hugepage分配内存的时候,预分配、&nbsp;而且这些分配的内存不能被其他进程占用,而且也不会交换到swap里面去。
</div>

<div style="background-color: inherit;">
    因为这边配置的,不够大,innodb引擎要求的比你分配的大,这点内存不够使用,所以转成使用常规内存了
</div>

<div style="background-color: inherit;">
    oracle这方面也出过案例,配置的内存小于SGA大小,白白的浪费那么多内存,造成是用到swap
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    既然报警说不够,查看官方文档,才知道大页内存大小要大于(innodb_buffer_pool_size+innodb_additional_mem_pool_size+innodb_log_buffer_size+tmp_table_size),那么刚才配置的显然不够
</div>

<div style="background-color: inherit;">
    那么我来慷慨点9300个大页也就是说有(9300*2M=18600M,有18.1G的内存),看看能正常启用大页的日志是怎么样的,再次启动mysql看看,这次就不报错了
</div>

<div style="background-color: inherit;">
    16:55:33&nbsp;mysqld_safe&nbsp;mysqld&nbsp;from&nbsp;pid&nbsp;file&nbsp;/data/3306/tmp/mysql.pid&nbsp;ended
</div>

<div style="background-color: inherit;">
    16:56:04&nbsp;mysqld_safe&nbsp;Starting&nbsp;mysqld&nbsp;daemon&nbsp;with&nbsp;databases&nbsp;from&nbsp;/data/3306/data
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:05&nbsp;0&nbsp;[Note]&nbsp;/opt/app/mysql/bin/mysqld&nbsp;(mysqld&nbsp;5.6.24-log)&nbsp;starting&nbsp;as&nbsp;process&nbsp;17256&nbsp;...
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:05&nbsp;17256&nbsp;[Note]&nbsp;Plugin&nbsp;&#39;FEDERATED&#39;&nbsp;is&nbsp;disabled.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:05&nbsp;7fa0048e5740&nbsp;InnoDB:&nbsp;Warning:&nbsp;Using&nbsp;innodb_additional_mem_pool_size&nbsp;is&nbsp;DEPRECATED.&nbsp;This&nbsp;option&nbsp;may&nbsp;be&nbsp;removed&nbsp;in&nbsp;future&nbsp;releases,&nbsp;together&nbsp;with&nbsp;the&nbsp;option&nbsp;innodb_use_sys_malloc&nbsp;and&nbsp;with&nbsp;the&nbsp;InnoDB&#39;s&nbsp;internal&nbsp;memory&nbsp;allocator.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:05&nbsp;17256&nbsp;[Note]&nbsp;InnoDB:&nbsp;Using&nbsp;atomics&nbsp;to&nbsp;ref&nbsp;count&nbsp;buffer&nbsp;pool&nbsp;pages
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:05&nbsp;17256&nbsp;[Note]&nbsp;InnoDB:&nbsp;The&nbsp;InnoDB&nbsp;memory&nbsp;heap&nbsp;is&nbsp;disabled
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:05&nbsp;17256&nbsp;[Note]&nbsp;InnoDB:&nbsp;Mutexes&nbsp;and&nbsp;rw_locks&nbsp;use&nbsp;GCC&nbsp;atomic&nbsp;builtins
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:05&nbsp;17256&nbsp;[Note]&nbsp;InnoDB:&nbsp;Memory&nbsp;barrier&nbsp;is&nbsp;not&nbsp;used
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:05&nbsp;17256&nbsp;[Note]&nbsp;InnoDB:&nbsp;Compressed&nbsp;tables&nbsp;use&nbsp;zlib&nbsp;1.2.3
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:05&nbsp;17256&nbsp;[Note]&nbsp;InnoDB:&nbsp;Using&nbsp;Linux&nbsp;native&nbsp;AIO
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:05&nbsp;17256&nbsp;[Note]&nbsp;InnoDB:&nbsp;Using&nbsp;CPU&nbsp;crc32&nbsp;instructions
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:05&nbsp;17256&nbsp;[Note]&nbsp;InnoDB:&nbsp;Initializing&nbsp;buffer&nbsp;pool,&nbsp;size&nbsp;=&nbsp;16.0G
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:06&nbsp;17256&nbsp;[Note]&nbsp;InnoDB:&nbsp;Completed&nbsp;initialization&nbsp;of&nbsp;buffer&nbsp;pool
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:06&nbsp;17256&nbsp;[Note]&nbsp;InnoDB:&nbsp;Highest&nbsp;supported&nbsp;file&nbsp;format&nbsp;is&nbsp;Barracuda.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:06&nbsp;17256&nbsp;[Note]&nbsp;InnoDB:&nbsp;128&nbsp;rollback&nbsp;segment(s)&nbsp;are&nbsp;active.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:06&nbsp;17256&nbsp;[Note]&nbsp;InnoDB:&nbsp;Waiting&nbsp;for&nbsp;purge&nbsp;to&nbsp;start
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:07&nbsp;17256&nbsp;[Note]&nbsp;InnoDB:&nbsp;5.6.24&nbsp;started;&nbsp;log&nbsp;sequence&nbsp;number&nbsp;26564145028
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:07&nbsp;17256&nbsp;[Note]&nbsp;Server&nbsp;hostname&nbsp;(bind-address):&nbsp;&#39;*&#39;;&nbsp;port:&nbsp;3306
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:07&nbsp;17256&nbsp;[Note]&nbsp;IPv6&nbsp;is&nbsp;available.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:07&nbsp;17256&nbsp;[Note]&nbsp;&nbsp;&nbsp;-&nbsp;&#39;::&#39;&nbsp;resolves&nbsp;to&nbsp;&#39;::&#39;;
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:07&nbsp;17256&nbsp;[Note]&nbsp;Server&nbsp;socket&nbsp;created&nbsp;on&nbsp;IP:&nbsp;&#39;::&#39;.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:07&nbsp;17256&nbsp;[Warning]&nbsp;Recovery&nbsp;from&nbsp;master&nbsp;pos&nbsp;155925988&nbsp;and&nbsp;file&nbsp;mysql-bin.000025.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:07&nbsp;17256&nbsp;[Warning]&nbsp;Storing&nbsp;MySQL&nbsp;user&nbsp;name&nbsp;or&nbsp;password&nbsp;information&nbsp;in&nbsp;the&nbsp;master&nbsp;info&nbsp;repository&nbsp;is&nbsp;not&nbsp;secure&nbsp;and&nbsp;is&nbsp;therefore&nbsp;not&nbsp;recommended.&nbsp;Please&nbsp;consider&nbsp;using&nbsp;the&nbsp;USER&nbsp;and&nbsp;PASSWORD&nbsp;connection&nbsp;options&nbsp;for&nbsp;START&nbsp;SLAVE;&nbsp;see&nbsp;the&nbsp;&#39;START&nbsp;SLAVE&nbsp;Syntax&#39;&nbsp;in&nbsp;the&nbsp;MySQL&nbsp;Manual&nbsp;for&nbsp;more&nbsp;information.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:07&nbsp;17256&nbsp;[Note]&nbsp;Slave&nbsp;SQL&nbsp;thread&nbsp;initialized,&nbsp;starting&nbsp;replication&nbsp;in&nbsp;log&nbsp;&#39;mysql-bin.000025&#39;&nbsp;at&nbsp;position&nbsp;155925988,&nbsp;relay&nbsp;log&nbsp;&#39;/data/3306/logs/relay-bin.000058&#39;&nbsp;position:&nbsp;4
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:07&nbsp;17256&nbsp;[Note]&nbsp;Slave&nbsp;I/O&nbsp;thread:&nbsp;connected&nbsp;to&nbsp;master&nbsp;&#39;[<font color="#0066cc">slave@172.16.117.247</font>](mailto:slave@172.16.117.247):3306&#39;,replication&nbsp;started&nbsp;in&nbsp;log&nbsp;&#39;mysql-bin.000025&#39;&nbsp;at&nbsp;position&nbsp;155925988
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:07&nbsp;17256&nbsp;[Note]&nbsp;Event&nbsp;Scheduler:&nbsp;Loaded&nbsp;0&nbsp;events
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;16:56:07&nbsp;17256&nbsp;[Note]&nbsp;/opt/app/mysql/bin/mysqld:&nbsp;ready&nbsp;for&nbsp;connections.
</div>

<div style="background-color: inherit;">
    Version:&nbsp;&#39;5.6.24-log&#39;&nbsp;&nbsp;socket:&nbsp;&#39;/data/3306/tmp/mysql.sock&#39;&nbsp;&nbsp;port:&nbsp;3306&nbsp;&nbsp;MySQL&nbsp;Community&nbsp;Server&nbsp;(GPL)
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@node-207</font>](mailto:root@node-207)&nbsp;~]#&nbsp;cat&nbsp;/proc/meminfo&nbsp;|&nbsp;grep&nbsp;^HugePages
</div>

<div style="background-color: inherit;">
    HugePages_Total:&nbsp;&nbsp;&nbsp;&nbsp;9300
</div>

<div style="background-color: inherit;">
    HugePages_Free:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;9067
</div>

<div style="background-color: inherit;">
    HugePages_Rsvd:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8178
</div>

<div style="background-color: inherit;">
    HugePages_Surp:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0
</div>

<div style="background-color: inherit;">
    Hugepagesize:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2048&nbsp;kB
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@node-207</font>](mailto:root@node-207)&nbsp;~]#&nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    因为大页内存是独占的,你给多了,也是浪费,那么根据计算公式设置合理的大页大小。
</div>

<div style="background-color: inherit;">
    然后根据公式在计算了一下
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    innodb_buffer_pool_size&nbsp;=&nbsp;16384M
</div>

<div style="background-color: inherit;">
    innodb_additional_mem_pool_size&nbsp;=&nbsp;16M
</div>

<div style="background-color: inherit;">
    innodb_log_buffer_size&nbsp;=&nbsp;32M
</div>

<div style="background-color: inherit;">
    tmp_table_size=512M
</div>

<div style="background-color: inherit;">
    max_heap_table_size=512M
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    (16384+16+32+512)=16944/2=8472,因为大页内存要比这个大,所以设置了8476,多了四个,因为这是独占的,设置多的也是不能使用的,一般多设置(2个大页以上,5个大页以下)
</div>

<div style="background-color: inherit;">
    注意这边指的临时表是max_heap_table_size这个参数值大小,是说允许创建内存引擎的临时表大小,
</div>

<div style="background-color: inherit;">
    下面我们来看看启动日志是不是正常
</div>

<div style="background-color: inherit;">
    17:14:23&nbsp;mysqld_safe&nbsp;Starting&nbsp;mysqld&nbsp;daemon&nbsp;with&nbsp;databases&nbsp;from&nbsp;/data/3306/data
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:23&nbsp;0&nbsp;[Note]&nbsp;/opt/app/mysql/bin/mysqld&nbsp;(mysqld&nbsp;5.6.24-log)&nbsp;starting&nbsp;as&nbsp;process&nbsp;18569&nbsp;...
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:23&nbsp;18569&nbsp;[Note]&nbsp;Plugin&nbsp;&#39;FEDERATED&#39;&nbsp;is&nbsp;disabled.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:23&nbsp;7fee7b559740&nbsp;InnoDB:&nbsp;Warning:&nbsp;Using&nbsp;innodb_additional_mem_pool_size&nbsp;is&nbsp;DEPRECATED.&nbsp;This&nbsp;option&nbsp;may&nbsp;be&nbsp;removed&nbsp;in&nbsp;future&nbsp;releases,&nbsp;together&nbsp;with&nbsp;the&nbsp;option&nbsp;innodb_use_sys_malloc&nbsp;and&nbsp;with&nbsp;the&nbsp;InnoDB&#39;s&nbsp;internal&nbsp;memory&nbsp;allocator.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:23&nbsp;18569&nbsp;[Note]&nbsp;InnoDB:&nbsp;Using&nbsp;atomics&nbsp;to&nbsp;ref&nbsp;count&nbsp;buffer&nbsp;pool&nbsp;pages
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:23&nbsp;18569&nbsp;[Note]&nbsp;InnoDB:&nbsp;The&nbsp;InnoDB&nbsp;memory&nbsp;heap&nbsp;is&nbsp;disabled
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:23&nbsp;18569&nbsp;[Note]&nbsp;InnoDB:&nbsp;Mutexes&nbsp;and&nbsp;rw_locks&nbsp;use&nbsp;GCC&nbsp;atomic&nbsp;builtins
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:23&nbsp;18569&nbsp;[Note]&nbsp;InnoDB:&nbsp;Memory&nbsp;barrier&nbsp;is&nbsp;not&nbsp;used
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:23&nbsp;18569&nbsp;[Note]&nbsp;InnoDB:&nbsp;Compressed&nbsp;tables&nbsp;use&nbsp;zlib&nbsp;1.2.3
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:23&nbsp;18569&nbsp;[Note]&nbsp;InnoDB:&nbsp;Using&nbsp;Linux&nbsp;native&nbsp;AIO
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:23&nbsp;18569&nbsp;[Note]&nbsp;InnoDB:&nbsp;Using&nbsp;CPU&nbsp;crc32&nbsp;instructions
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:23&nbsp;18569&nbsp;[Note]&nbsp;InnoDB:&nbsp;Initializing&nbsp;buffer&nbsp;pool,&nbsp;size&nbsp;=&nbsp;16.0G
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:24&nbsp;18569&nbsp;[Note]&nbsp;InnoDB:&nbsp;Completed&nbsp;initialization&nbsp;of&nbsp;buffer&nbsp;pool
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:24&nbsp;18569&nbsp;[Note]&nbsp;InnoDB:&nbsp;Highest&nbsp;supported&nbsp;file&nbsp;format&nbsp;is&nbsp;Barracuda.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:25&nbsp;18569&nbsp;[Note]&nbsp;InnoDB:&nbsp;128&nbsp;rollback&nbsp;segment(s)&nbsp;are&nbsp;active.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:25&nbsp;18569&nbsp;[Note]&nbsp;InnoDB:&nbsp;Waiting&nbsp;for&nbsp;purge&nbsp;to&nbsp;start
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:25&nbsp;18569&nbsp;[Note]&nbsp;InnoDB:&nbsp;5.6.24&nbsp;started;&nbsp;log&nbsp;sequence&nbsp;number&nbsp;26585446708
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:25&nbsp;18569&nbsp;[Note]&nbsp;Server&nbsp;hostname&nbsp;(bind-address):&nbsp;&#39;*&#39;;&nbsp;port:&nbsp;3306
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:25&nbsp;18569&nbsp;[Note]&nbsp;IPv6&nbsp;is&nbsp;available.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:25&nbsp;18569&nbsp;[Note]&nbsp;&nbsp;&nbsp;-&nbsp;&#39;::&#39;&nbsp;resolves&nbsp;to&nbsp;&#39;::&#39;;
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:25&nbsp;18569&nbsp;[Note]&nbsp;Server&nbsp;socket&nbsp;created&nbsp;on&nbsp;IP:&nbsp;&#39;::&#39;.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:25&nbsp;18569&nbsp;[Warning]&nbsp;Recovery&nbsp;from&nbsp;master&nbsp;pos&nbsp;166617263&nbsp;and&nbsp;file&nbsp;mysql-bin.000025.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:25&nbsp;18569&nbsp;[Warning]&nbsp;Storing&nbsp;MySQL&nbsp;user&nbsp;name&nbsp;or&nbsp;password&nbsp;information&nbsp;in&nbsp;the&nbsp;master&nbsp;info&nbsp;repository&nbsp;is&nbsp;not&nbsp;secure&nbsp;and&nbsp;is&nbsp;therefore&nbsp;not&nbsp;recommended.&nbsp;Please&nbsp;consider&nbsp;using&nbsp;the&nbsp;USER&nbsp;and&nbsp;PASSWORD&nbsp;connection&nbsp;options&nbsp;for&nbsp;START&nbsp;SLAVE;&nbsp;see&nbsp;the&nbsp;&#39;START&nbsp;SLAVE&nbsp;Syntax&#39;&nbsp;in&nbsp;the&nbsp;MySQL&nbsp;Manual&nbsp;for&nbsp;more&nbsp;information.
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:25&nbsp;18569&nbsp;[Note]&nbsp;Slave&nbsp;SQL&nbsp;thread&nbsp;initialized,&nbsp;starting&nbsp;replication&nbsp;in&nbsp;log&nbsp;&#39;mysql-bin.000025&#39;&nbsp;at&nbsp;position&nbsp;166617263,&nbsp;relay&nbsp;log&nbsp;&#39;/data/3306/logs/relay-bin.000060&#39;&nbsp;position:&nbsp;4
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:25&nbsp;18569&nbsp;[Note]&nbsp;Slave&nbsp;I/O&nbsp;thread:&nbsp;connected&nbsp;to&nbsp;master&nbsp;&#39;[<font color="#0066cc">slave@172.16.117.247</font>](mailto:slave@172.16.117.247):3306&#39;,replication&nbsp;started&nbsp;in&nbsp;log&nbsp;&#39;mysql-bin.000025&#39;&nbsp;at&nbsp;position&nbsp;166617263
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:25&nbsp;18569&nbsp;[Note]&nbsp;Event&nbsp;Scheduler:&nbsp;Loaded&nbsp;0&nbsp;events
</div>

<div style="background-color: inherit;">
    2015-07-28&nbsp;17:14:25&nbsp;18569&nbsp;[Note]&nbsp;/opt/app/mysql/bin/mysqld:&nbsp;ready&nbsp;for&nbsp;connections.
</div>

<div style="background-color: inherit;">
    Version:&nbsp;&#39;5.6.24-log&#39;&nbsp;&nbsp;socket:&nbsp;&#39;/data/3306/tmp/mysql.sock&#39;&nbsp;&nbsp;port:&nbsp;3306&nbsp;&nbsp;MySQL&nbsp;Community&nbsp;Server&nbsp;(GPL)
</div>

<div style="background-color: inherit;">
    OK,非常好
</div>

<div style="background-color: inherit;">
    那么我们来看看大页内存使用了多少,
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@node-207</font>](mailto:root@node-207)&nbsp;~]#&nbsp;cat&nbsp;/proc/meminfo&nbsp;|&nbsp;grep&nbsp;^HugePages
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    HugePages_Total:&nbsp;&nbsp;&nbsp;&nbsp;8476
</div>

<div style="background-color: inherit;">
    HugePages_Free:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8202
</div>

<div style="background-color: inherit;">
    HugePages_Rsvd:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8137
</div>

<div style="background-color: inherit;">
    HugePages_Surp:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0
</div>

<div style="background-color: inherit;">
    Hugepagesize:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2048&nbsp;kB
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@node-207</font>](mailto:root@node-207)&nbsp;~]#&nbsp;
</div>

<div style="background-color: inherit;">
    才使用了一点点
</div>

<div style="background-color: inherit;">
    HugePages_Total:&nbsp;&nbsp;&nbsp;&nbsp;8476
</div>

<div style="background-color: inherit;">
    HugePages_Free:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8202
</div>

<div style="background-color: inherit;">
    HugePages_Rsvd:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8137
</div>

<div style="background-color: inherit;">
    Hugepagesize:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2048&nbsp;kB
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    那么我们来个大表count(主键)
</div>

<div style="background-color: inherit;">
    再来看看
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@node-207</font>](mailto:root@node-207)&nbsp;~]#&nbsp;cat&nbsp;/proc/meminfo&nbsp;|&nbsp;grep&nbsp;^HugePages
</div>

<div style="background-color: inherit;">
    HugePages_Total:&nbsp;&nbsp;&nbsp;&nbsp;8476
</div>

<div style="background-color: inherit;">
    HugePages_Free:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8123
</div>

<div style="background-color: inherit;">
    HugePages_Rsvd:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8058
</div>

<div style="background-color: inherit;">
    HugePages_Surp:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0
</div>

<div style="background-color: inherit;">
    Hugepagesize:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2048&nbsp;kB
</div>

<div style="background-color: inherit;">
    [[<font color="#0066cc">root@node-207</font>](mailto:root@node-207)&nbsp;~]#&nbsp;cat&nbsp;/proc/meminfo&nbsp;|&nbsp;grep&nbsp;^HugePages
</div>

<div style="background-color: inherit;">
    HugePages_Total:&nbsp;&nbsp;&nbsp;&nbsp;8476
</div>

<div style="background-color: inherit;">
    HugePages_Free:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7233
</div>

<div style="background-color: inherit;">
    HugePages_Rsvd:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7201
</div>

<div style="background-color: inherit;">
    HugePages_Surp:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0
</div>

<div style="background-color: inherit;">
    Hugepagesize:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2048&nbsp;kB
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    ####看到木有,有在使用大页了&nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    HugePages_Free:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8123
</div>

<div style="background-color: inherit;">
    ####
</div>

<div style="background-color: inherit;">
    HugePages_Free:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7233
</div>

<div style="background-color: inherit;">
    在看看innodb情况,算起来是用了那么多内存,到此大页内存是配置好了
</div>

<div style="background-color: inherit;">
    ---BUFFER&nbsp;POOL&nbsp;7
</div>

<div style="background-color: inherit;">
    Buffer&nbsp;pool&nbsp;size&nbsp;&nbsp;&nbsp;131072
</div>

<div style="background-color: inherit;">
    Free&nbsp;buffers&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;113960
</div>

<div style="background-color: inherit;">
    Database&nbsp;pages&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;17102
</div>

<div style="background-color: inherit;">
    Old&nbsp;database&nbsp;pages&nbsp;8571
</div>

<div style="background-color: inherit;">
    Modified&nbsp;db&nbsp;pages&nbsp;&nbsp;1164
</div>

<div style="background-color: inherit;">
    Pending&nbsp;reads&nbsp;0
</div>

<div style="background-color: inherit;">
    Pending&nbsp;writes:&nbsp;LRU&nbsp;0,&nbsp;flush&nbsp;list&nbsp;0,&nbsp;single&nbsp;page&nbsp;0
</div>

<div style="background-color: inherit;">
    Pages&nbsp;made&nbsp;young&nbsp;55,&nbsp;not&nbsp;young&nbsp;0
</div>

<div style="background-color: inherit;">
    0.13&nbsp;youngs/s,&nbsp;0.00&nbsp;non-youngs/s
</div>

<div style="background-color: inherit;">
    Pages&nbsp;read&nbsp;17080,&nbsp;created&nbsp;22,&nbsp;written&nbsp;1056
</div>

<div style="background-color: inherit;">
    0.80&nbsp;reads/s,&nbsp;0.00&nbsp;creates/s,&nbsp;3.33&nbsp;writes/s
</div>

<div style="background-color: inherit;">
    Buffer&nbsp;pool&nbsp;hit&nbsp;rate&nbsp;974&nbsp;/&nbsp;1000,&nbsp;young-making&nbsp;rate&nbsp;4&nbsp;/&nbsp;1000&nbsp;not&nbsp;0&nbsp;/&nbsp;1000
</div>

<div style="background-color: inherit;">
    Pages&nbsp;read&nbsp;ahead&nbsp;0.00/s,&nbsp;evicted&nbsp;without&nbsp;access&nbsp;0.00/s,&nbsp;Random&nbsp;read&nbsp;ahead&nbsp;0.00/s
</div>

<div style="background-color: inherit;">
    LRU&nbsp;len:&nbsp;17102,&nbsp;unzip_LRU&nbsp;len:&nbsp;0
</div>

<div style="background-color: inherit;">
    I/O&nbsp;sum[0]:cur[4],&nbsp;unzip&nbsp;sum[0]:cur[0]
</div>

<div style="background-color: inherit;">
    --------------
</div>

<div style="background-color: inherit;">
    ROW&nbsp;OPERATIONS
</div>

<div style="background-color: inherit;">
    --------------
</div>

<div style="background-color: inherit;">
    queries&nbsp;inside&nbsp;InnoDB,&nbsp;0&nbsp;queries&nbsp;in&nbsp;queue
</div>

<div style="background-color: inherit;">
    read&nbsp;views&nbsp;open&nbsp;inside&nbsp;InnoDB
</div>

<div style="background-color: inherit;">
    Main&nbsp;thread&nbsp;process&nbsp;no.&nbsp;18569,&nbsp;id&nbsp;140659839203072,&nbsp;state:&nbsp;sleeping
</div>

<div style="background-color: inherit;">
    Number&nbsp;of&nbsp;rows&nbsp;inserted&nbsp;12222,&nbsp;updated&nbsp;10955,&nbsp;deleted&nbsp;184,&nbsp;read&nbsp;1819484
</div>

<div style="background-color: inherit;">
    10.53&nbsp;inserts/s,&nbsp;7.67&nbsp;updates/s,&nbsp;0.40&nbsp;deletes/s,&nbsp;8.07&nbsp;reads/s
</div>

<div style="background-color: inherit;">
    ----------------------------
</div>

<div style="background-color: inherit;">
    END&nbsp;OF&nbsp;INNODB&nbsp;MONITOR&nbsp;OUTPUT
</div>

<div style="background-color: inherit;">
    ============================
</div>

<div style="background-color: inherit;">
    row&nbsp;in&nbsp;set&nbsp;(0.00&nbsp;sec)
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    参考资料:
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    [<font color="#0066cc">https://dev.mysql.com/doc/refman/5.0/en/large-page-support.html</font>](https://dev.mysql.com/doc/refman/5.0/en/large-page-support.html)
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    I&nbsp;hope&nbsp;this&nbsp;comment&nbsp;will&nbsp;save&nbsp;severals&nbsp;hours&nbsp;and&nbsp;white&nbsp;nights&nbsp;on&nbsp;production&nbsp;launching...
</div>

<div style="background-color: inherit;">
    After&nbsp;folowing&nbsp;every&nbsp;How-to&nbsp;and&nbsp;all&#39;s&nbsp;documentation&nbsp;over&nbsp;Google,&nbsp;to&nbsp;enable&nbsp;huge&nbsp;pages...&nbsp;i&nbsp;must&nbsp;give&nbsp;you&nbsp;this&nbsp;post.
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    For&nbsp;enabling&nbsp;huge&nbsp;pages&nbsp;with&nbsp;Linux&nbsp;Debian&nbsp;6.0.5&nbsp;on&nbsp;
</div>

<div style="background-color: inherit;">
    Linux&nbsp;2.6.32-5-amd64&nbsp;#x86_64&nbsp;GNU/Linux&nbsp;(64Bits)
</div>

<div style="background-color: inherit;">
    and&nbsp;MySQL&nbsp;5.1,&nbsp;you&nbsp;got&nbsp;to&nbsp;add&nbsp;this&nbsp;your&nbsp;/etc/sysctl.conf&nbsp;:
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    #&nbsp;Total&nbsp;of&nbsp;allowed&nbsp;memory
</div>

<div style="background-color: inherit;">
    vm.nr_hugepages&nbsp;=&nbsp;YYYYYY
</div>

<div style="background-color: inherit;">
    #&nbsp;total&nbsp;amount&nbsp;of&nbsp;memory&nbsp;that&nbsp;can&nbsp;be&nbsp;allocated&nbsp;to&nbsp;shared&nbsp;memory,&nbsp;huge&nbsp;pages&nbsp;or&nbsp;not,&nbsp;on&nbsp;the&nbsp;box
</div>

<div style="background-color: inherit;">
    kernel.shmall&nbsp;=&nbsp;XXXXXXXXXX
</div>

<div style="background-color: inherit;">
    #&nbsp;maximum&nbsp;single&nbsp;shared&nbsp;memory&nbsp;segment,&nbsp;which&nbsp;for&nbsp;me&nbsp;was&nbsp;basically&nbsp;innodb_buffer_pool+1%
</div>

<div style="background-color: inherit;">
    kernel.shmmax&nbsp;=&nbsp;XXXXXXXXXX
</div>

<div style="background-color: inherit;">
    #&nbsp;Groupe&nbsp;autoris&eacute;
</div>

<div style="background-color: inherit;">
    vm.hugetlb_shm_group&nbsp;=&nbsp;`id&nbsp;-g&nbsp;mysql`
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    XXXXX&nbsp;is&nbsp;given&nbsp;by&nbsp;this&nbsp;script&nbsp;shell&nbsp;in&nbsp;bash&nbsp;:
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    #####&nbsp;SCRIPT&nbsp;START&nbsp;#########
</div>

<div style="background-color: inherit;">
    #!/bin/bash
</div>

<div style="background-color: inherit;">
    #&nbsp;keep&nbsp;2go&nbsp;memory&nbsp;for&nbsp;system
</div>

<div style="background-color: inherit;">
    #&nbsp;(i&nbsp;got&nbsp;68Go&nbsp;on&nbsp;this&nbsp;one&nbsp;ans&nbsp;128Go&nbsp;RAM&nbsp;on&nbsp;other&nbsp;one)
</div>

<div style="background-color: inherit;">
    keep_for_system=2097152
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    mem=$(free|grep&nbsp;Mem|awk&nbsp;&#39;{print$2}&#39;)
</div>

<div style="background-color: inherit;">
    mem=$(echo&nbsp;&quot;$mem-$marge&quot;|bc)
</div>

<div style="background-color: inherit;">
    totmem=$(echo&nbsp;&quot;$mem*1024&quot;|bc)
</div>

<div style="background-color: inherit;">
    huge=$(grep&nbsp;Hugepagesize&nbsp;/proc/meminfo|awk&nbsp;&#39;{print&nbsp;$2}&#39;)
</div>

<div style="background-color: inherit;">
    max=$(echo&nbsp;&quot;$totmem*75/100&quot;|bc)
</div>

<div style="background-color: inherit;">
    all=$(echo&nbsp;&quot;$max/$huge&quot;|bc)
</div>

<div style="background-color: inherit;">
    echo&nbsp;&quot;kernel.shmmax&nbsp;=&nbsp;$max&quot;
</div>

<div style="background-color: inherit;">
    echo&nbsp;&quot;kernel.shmall&nbsp;=&nbsp;$all&quot;
</div>

<div style="background-color: inherit;">
    #########&nbsp;SCRIPT&nbsp;END&nbsp;#########
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    check&nbsp;memory&nbsp;usage&nbsp;before&nbsp;reboot&nbsp;by&nbsp;command&nbsp;:
</div>

<div style="background-color: inherit;">
    cat&nbsp;/proc/meminfo&nbsp;|&nbsp;grep&nbsp;-i&nbsp;huge
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    Reboot&nbsp;your&nbsp;system.
</div>

<div style="background-color: inherit;">
    and&nbsp;check&nbsp;memory&nbsp;usage&nbsp;again.
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    It&nbsp;works&nbsp;!
</div>

<div style="background-color: inherit;">
    ;-)
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    Posted&nbsp;by&nbsp;John&nbsp;Anderson&nbsp;on&nbsp;May&nbsp;13&nbsp;2015&nbsp;11:09am&nbsp;[Delete]&nbsp;[Edit]&nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    A&nbsp;bit&nbsp;of&nbsp;a&nbsp;note&nbsp;on&nbsp;the&nbsp;math&nbsp;here,&nbsp;some&nbsp;articles&nbsp;and&nbsp;blogs&nbsp;say&nbsp;that&nbsp;you&nbsp;should&nbsp;add&nbsp;your&nbsp;innodb_buffer_pool&nbsp;size&nbsp;to&nbsp;your&nbsp;innodb_additional_mem_pool_size,&nbsp;and&nbsp;divide&nbsp;that&nbsp;by&nbsp;your&nbsp;hugetlb&nbsp;page&nbsp;size.&nbsp;Then&nbsp;add&nbsp;a&nbsp;few&nbsp;on&nbsp;to&nbsp;that.&nbsp;Unfortunately,&nbsp;that&nbsp;doesn&#39;t&nbsp;seem&nbsp;to&nbsp;be&nbsp;the&nbsp;whole&nbsp;story.
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    For&nbsp;those&nbsp;who&nbsp;want&nbsp;to&nbsp;allocate&nbsp;as&nbsp;little&nbsp;RAM&nbsp;as&nbsp;possible&nbsp;to&nbsp;HugeTLB&nbsp;while&nbsp;still&nbsp;satisfying&nbsp;the&nbsp;requirements&nbsp;outlined&nbsp;in&nbsp;my.cnf,&nbsp;this&nbsp;formula&nbsp;might&nbsp;be&nbsp;a&nbsp;little&nbsp;better.&nbsp;This&nbsp;is&nbsp;after&nbsp;some&nbsp;experimentation&nbsp;led&nbsp;me&nbsp;to&nbsp;put&nbsp;some&nbsp;effort&nbsp;behind&nbsp;finding&nbsp;out&nbsp;why&nbsp;I&nbsp;always&nbsp;had&nbsp;to&nbsp;allocate&nbsp;many&nbsp;more&nbsp;pages&nbsp;than&nbsp;the&nbsp;math&nbsp;suggested.
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    The&nbsp;real&nbsp;formula&nbsp;should&nbsp;be:
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    (innodb_buffer_pool_size&nbsp;in&nbsp;kb&nbsp;+
</div>

<div style="background-color: inherit;">
    innodb_additional_mem_pool_size&nbsp;in&nbsp;kb&nbsp;+&nbsp;
</div>

<div style="background-color: inherit;">
    tmp_table_size&nbsp;in&nbsp;kb&nbsp;+&nbsp;
</div>

<div style="background-color: inherit;">
    innodb_log_buffer_size&nbsp;in&nbsp;kb)&nbsp;/&nbsp;hugetlb&nbsp;size&nbsp;in&nbsp;kb
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    Then&nbsp;to&nbsp;that,&nbsp;add&nbsp;an&nbsp;additional&nbsp;11&nbsp;-&nbsp;15&nbsp;pages&nbsp;until&nbsp;MySQL&nbsp;starts.&nbsp;I&nbsp;give&nbsp;my&nbsp;best&nbsp;guess&nbsp;as&nbsp;to&nbsp;why&nbsp;these&nbsp;pages&nbsp;are&nbsp;unaccounted&nbsp;for&nbsp;below.&nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    First,&nbsp;a&nbsp;note&nbsp;on&nbsp;why&nbsp;tmp_table_size&nbsp;is&nbsp;included:&nbsp;I&#39;m&nbsp;not&nbsp;sure&nbsp;if&nbsp;it&nbsp;*should*&nbsp;be&nbsp;tmp_table_size&nbsp;*&nbsp;max_tmp_tables,&nbsp;but&nbsp;MySQL&nbsp;starts&nbsp;and&nbsp;runs&nbsp;with&nbsp;only&nbsp;tmp_table_size&nbsp;included.&nbsp;
</div>

<div style="background-color: inherit;">
    I&nbsp;think&nbsp;this&nbsp;only&nbsp;applies&nbsp;if&nbsp;default_tmp_storage_engine&nbsp;is&nbsp;InnoDB.&nbsp;
</div>

<div style="background-color: inherit;">
    If&nbsp;a&nbsp;tmp&nbsp;table&nbsp;needs&nbsp;to&nbsp;be&nbsp;created&nbsp;for&nbsp;a&nbsp;sort&nbsp;or&nbsp;order,&nbsp;and&nbsp;that&nbsp;table&nbsp;is&nbsp;going&nbsp;to&nbsp;be&nbsp;InnoDB&nbsp;in&nbsp;RAM,&nbsp;then&nbsp;hugetlb&nbsp;will&nbsp;need&nbsp;to&nbsp;be&nbsp;used.
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    Secondly,&nbsp;I&nbsp;noticed&nbsp;in&nbsp;the&nbsp;source&nbsp;code&nbsp;that&nbsp;the&nbsp;InnoDB&nbsp;buffer&nbsp;log&nbsp;uses&nbsp;the&nbsp;&#39;os_mem_alloc_large&#39;&nbsp;function.&nbsp;
</div>

<div style="background-color: inherit;">
    So&nbsp;I&nbsp;think&nbsp;that&nbsp;should&nbsp;be&nbsp;included&nbsp;in&nbsp;the&nbsp;calculation&nbsp;as&nbsp;well.&nbsp;In&nbsp;my&nbsp;experimentation,&nbsp;I&nbsp;had&nbsp;22&nbsp;pages&nbsp;unaccounted&nbsp;for&nbsp;until&nbsp;I&nbsp;found&nbsp;that,&nbsp;
</div>

<div style="background-color: inherit;">
    then&nbsp;my&nbsp;unaccounted&nbsp;for&nbsp;pages&nbsp;went&nbsp;down&nbsp;to&nbsp;11.
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    As&nbsp;for&nbsp;the&nbsp;pages&nbsp;which&nbsp;don&#39;t&nbsp;seem&nbsp;to&nbsp;be&nbsp;accounted&nbsp;for,&nbsp;I&nbsp;think&nbsp;that&nbsp;is&nbsp;the&nbsp;overhead&nbsp;cost&nbsp;of&nbsp;the&nbsp;nature&nbsp;of&nbsp;pages.&nbsp;
</div>

<div style="background-color: inherit;">
    For&nbsp;instance,&nbsp;if&nbsp;you&nbsp;have&nbsp;an&nbsp;innodb_buffer_pool&nbsp;size&nbsp;of&nbsp;256&nbsp;MB,&nbsp;and&nbsp;you&nbsp;have&nbsp;8&nbsp;buffer&nbsp;instances&nbsp;then&nbsp;you&nbsp;have:
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    &nbsp;(268435456&nbsp;bytes&nbsp;/&nbsp;8&nbsp;instances&nbsp;)&nbsp;=&nbsp;33554.4&nbsp;kilobtes&nbsp;to&nbsp;allocate&nbsp;per&nbsp;page.
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    At&nbsp;2048&nbsp;KB&nbsp;per&nbsp;page,&nbsp;that&nbsp;comes&nbsp;to&nbsp;16.4&nbsp;pages&nbsp;per&nbsp;buffer.&nbsp;That&nbsp;.4&nbsp;of&nbsp;a&nbsp;page&nbsp;means&nbsp;an&nbsp;entire&nbsp;page&nbsp;must&nbsp;be&nbsp;allocated,&nbsp;or&nbsp;17&nbsp;pages&nbsp;per&nbsp;buffer&nbsp;instead&nbsp;of&nbsp;16.4.&nbsp;
</div>

<div style="background-color: inherit;">
    That&nbsp;would&nbsp;account&nbsp;for&nbsp;8&nbsp;pages&nbsp;right&nbsp;there.&nbsp;So&nbsp;if&nbsp;one&nbsp;is&nbsp;really&nbsp;picky,&nbsp;declaring&nbsp;buffer&nbsp;sizes&nbsp;that&nbsp;meet&nbsp;the&nbsp;page&nbsp;size&nbsp;exactly&nbsp;would&nbsp;theoretically&nbsp;leave&nbsp;no&nbsp;overhead&nbsp;to&nbsp;absorb.&nbsp;
</div>

<div style="background-color: inherit;">
    I&nbsp;don&#39;t&nbsp;know&nbsp;why&nbsp;but&nbsp;MySQL&nbsp;and&nbsp;google&nbsp;convert&nbsp;have&nbsp;differing&nbsp;opinions&nbsp;on&nbsp;how&nbsp;to&nbsp;convert&nbsp;megabytes&nbsp;to&nbsp;bytes,&nbsp;and&nbsp;vice&nbsp;versa.&nbsp;
</div>

<div style="background-color: inherit;">
    So&nbsp;if&nbsp;you&nbsp;want&nbsp;to&nbsp;cut&nbsp;it&nbsp;as&nbsp;close&nbsp;as&nbsp;possible,&nbsp;fill&nbsp;out&nbsp;your&nbsp;my.cnf.&nbsp;Start&nbsp;mysql&nbsp;without&nbsp;large-pages,&nbsp;and&nbsp;take&nbsp;note&nbsp;of&nbsp;the&nbsp;values&nbsp;of&nbsp;these&nbsp;4&nbsp;variables.&nbsp;
</div>

<div style="background-color: inherit;">
    Then&nbsp;convert&nbsp;those&nbsp;values&nbsp;into&nbsp;kilobytes&nbsp;for&nbsp;the&nbsp;page&nbsp;count&nbsp;calculation.
</div>


 

####


http://www.cnblogs.com/LMySQL/p/4689868.html