Linux hugepages and MySQL large page configuration

Source: Internet
Author: User

http://blog.csdn.net/dba_waterbin/article/details/9669929 ㈠hugepages Introduction

Hugepages is introduced in kernel 2.6 to accommodate ever larger physical memory
Under Linux, page size defaults to 4K, if you use Hugepages, the default is 2M

Look at 2 more terms:
Page Table Mapping Table: physical memory and swap correspondence, access memory is read page table first, according to table mapping relationship operation
TLB:CPU cache component, caching part of page table to increase conversion speed



㈡mysql Configuring large pages

Benefits

① increase the hit rate of the TLB
② uses hugepages to ensure that MySQL memory is not swapped for swap

Currently in MySQL, Hugepages is supported only by InnoDB

The following is a brief introduction to its configuration process

⑴ before configuration:

[Plain]View PlainCopyprint?
    1. [Email protected] ~]# Cat/proc/meminfo | Grep-i Huge
    2. hugepages_total:0
    3. hugepages_free:0
    4. hugepages_rsvd:0
    5. hugepagesize:2048 KB

⑵ set the number of large pages, each page is usually 2M, 20 40M, the system should have enough memory to allocate

[Plain]View PlainCopy print?
    1. [Email protected] ~]# echo >/proc/sys/vm/nr_hugepages

⑶ increase the size of the maximum shared memory segment, this example 12G

[Plain]View PlainCopyprint?
    1. [Email protected] ~]# echo 1560281088 >/proc/sys/kernel/shmmax

⑷ increase the size of shared memory, 4K per page

[Plain]View PlainCopyprint?
    1. [Email protected] ~]# echo 4194304 >/proc/sys/kernel/shmall

⑸ Adding a MySQL user-owned group to the system kernel

[Plain]View PlainCopyprint?
    1. [Email protected] ~]# More/proc/sys/vm/hugetlb_shm_group
    2. 0
    3. [[email protected] ~]# ID mysql
    4. uid=501 (MySQL) gid=501 (dba) groups=501 (DBA)
    5. [Email protected] ~]# echo 501 >/proc/sys/vm/hugetlb_shm_group

⑹ re-confirm configuration status

[Plain]View PlainCopyprint?
    1. [Email protected] ~]# Cat/proc/meminfo | Grep-i Huge
    2. Hugepages_total:20
    3. Hugepages_free:20
    4. hugepagesize:4096 KB

⑺ setting max locked memory

[Plain]View PlainCopyprint?
    1. [Email protected] ~]# cat/etc/security/limits.conf | Grep-i MySQL
    2. MySQL Hard Memlock Unlimited
    3. MySQL Soft Memlock Unlimited

⑻ Configuration My.cnf

[Plain]View PlainCopyprint?
    1. [Mysqld]
    2. Large-pages

⑼ Start mysqld

⑽ observation of hugepages usage

[Plain]View PlainCopyprint?
    1. [Email protected] ~]# grep-i huge/proc/meminfo
    2. Hugepages_total:20
    3. Hugepages_free:16
    4. hugepagesize:4096 KB

Linux hugepages and MySQL large page configuration

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.