Linux hugepages and MySQL large page configuration

Source: Internet
Author: User
(I) hugepages Introduction

Hugepages is introduced by kernel 2.6 to adapt to the increasing physical memory size.
In Linux, the default page size is 4 K. If hugepages is used, the default page size is 2 m.

Let's look at two more terms:
Page table ing table: the correspondence between physical memory and swap, the access memory is to read the page table first, and operations based on the ing relationship in the table
TLB: CPU cache component, cache part of the page table to improve the conversion speed



(Ii) MySQL configuration page

Benefits

① Improve the TLB hit rate
② Using the feature that hugepages will not be swap to ensure that MySQL memory will not be switched to swap

Currently, hugepages in MySQL is only supported by InnoDB.

The following describes the configuration process.

(1) Before Configuration:

[root@cdio ~]# cat /proc/meminfo | grep -i hugeHugePages_Total:     0HugePages_Free:      0HugePages_Rsvd:      0Hugepagesize:     2048 kB

(2) Set a large number of pages, usually 2 MB for each page, 20 for 40 MB, and the system should have enough memory to be allocated.

[root@obe11g ~]# echo 20 > /proc/sys/vm/nr_hugepages

(3) increase the size of the maximum shared memory segment. In this example, 12 GB is used.

[root@obe11g ~]# echo 1560281088 > /proc/sys/kernel/shmmax

(4) increase the size of shared memory, 4 K per page

[root@obe11g ~]# echo 4194304 > /proc/sys/kernel/shmall

⑸ Add the group to which the MySQL user belongs to the system kernel.

[root@obe11g ~]# more /proc/sys/vm/hugetlb_shm_group0[root@obe11g ~]# id mysqluid=501(mysql) gid=501(dba) groups=501(dba)[root@obe11g ~]# echo 501 > /proc/sys/vm/hugetlb_shm_group

Confirm configuration again

[root@obe11g ~]# cat /proc/meminfo | grep -i hugeHugePages_Total:    20HugePages_Free:     20Hugepagesize:     4096 kB

Set max locked memory in memory

[root@obe11g ~]# cat /etc/security/limits.conf  | grep -i mysqlmysql            hard    memlock         unlimitedmysql            soft    memlock         unlimited

Configure My. CNF

[mysqld]large-pages

⑼ Start mysqld

⑽ Observe hugepages usage

[root@obe11g ~]# grep -i huge /proc/meminfoHugePages_Total:    20HugePages_Free:     16Hugepagesize:     4096 kB

By dba_waterbin

2013-07-31

Good luck

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.