Set MySQL memory usage page

Source: Internet
Author: User

Generally, the memory used is 4 kb per page. If the huge page is used, the default memory is 2 MB per page. If you set MySQL to use the huge page, there are at least two advantages: one is to reduce the errors of the translation lookaside buffer (TLB) to improve performance, the other is to ensure that MySQL memory is not exchanged to swap by using the feature that the huge page does not use swap.
MySQL 5.0.3 and later support the huge page on Linux. You can use the large-page option to start MySQL.
Of course there are some related system settings.


echo 400 > /proc/sys/vm/nr_hugepages

This specifies the total number of huge pages, which can be placed in/etc/rc. Local. Because the allocation requires continuous memory space, if the execution is performed on the system for a period of time, it may not be allocated to the specified amount, even if there is enough memory.

You also need to set the kernel parameters kernel. shmmax and kernel. Shmall. Otherwise, MySQL will report the 22 error at startup.

InnoDB: HugeTLB: Warning: Failed to allocate 536887296 bytes. errno 22

Shmmax is the maximum size of the shared memory segment, in bytes. The default value is 32 MB, which is definitely not enough. This should be larger than innodb_buffer_pool. Shmall indicates the total size of the shared memory. The unit is page. The default value is 2097152 (8 GB ). You can use sysctl-W or set it in/etc/sysctl. conf.

In addition, you also need to set Max locked memory, use ulimit-l or set/etc/security/limits. conf. Otherwise, a 12 error will be reported:

Warning: Failed to allocate 31457280 bytes from HugeTLB memory. errno 12

MySQL can be used after startup

grep Huge /proc/meminfo

View the usage of the huge page.

HugePages_Total:   400
HugePages_Free: 128
Hugepagesize: 2048 kB

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.