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?
- [Email protected] ~]# Cat/proc/meminfo | Grep-i Huge
- hugepages_total:0
- hugepages_free:0
- hugepages_rsvd:0
- 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?
- [Email protected] ~]# echo >/proc/sys/vm/nr_hugepages
⑶ increase the size of the maximum shared memory segment, this example 12G
[Plain]View PlainCopyprint?
- [Email protected] ~]# echo 1560281088 >/proc/sys/kernel/shmmax
⑷ increase the size of shared memory, 4K per page
[Plain]View PlainCopyprint?
- [Email protected] ~]# echo 4194304 >/proc/sys/kernel/shmall
⑸ Adding a MySQL user-owned group to the system kernel
[Plain]View PlainCopyprint?
- [Email protected] ~]# More/proc/sys/vm/hugetlb_shm_group
- 0
- [[email protected] ~]# ID mysql
- uid=501 (MySQL) gid=501 (dba) groups=501 (DBA)
- [Email protected] ~]# echo 501 >/proc/sys/vm/hugetlb_shm_group
⑹ re-confirm configuration status
[Plain]View PlainCopyprint?
- [Email protected] ~]# Cat/proc/meminfo | Grep-i Huge
- Hugepages_total:20
- Hugepages_free:20
- hugepagesize:4096 KB
⑺ setting max locked memory
[Plain]View PlainCopyprint?
- [Email protected] ~]# cat/etc/security/limits.conf | Grep-i MySQL
- MySQL Hard Memlock Unlimited
- MySQL Soft Memlock Unlimited
⑻ Configuration My.cnf
[Plain]View PlainCopyprint?
- [Mysqld]
- Large-pages
⑼ Start mysqld
⑽ observation of hugepages usage
[Plain]View PlainCopyprint?
- [Email protected] ~]# grep-i huge/proc/meminfo
- Hugepages_total:20
- Hugepages_free:16
- hugepagesize:4096 KB
Linux hugepages and MySQL large page configuration