mysql大页内存的使用

一些系统支持内存页大于默认的4KB,有很多内存访问的应用通过使用大页内存可以减少Translation Lookaside Buffer的缺失。

在mysql中,大页内存可以被InnoDB使用,来分配buffer pool和别的内存

查看是否支持大页内存

shell> cat /proc/meminfo | grep -i huge
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       4096 kB

设置系统

# Set the number of pages to be used.
# Each page is normally 2MB, so a value of 20 = 40MB.
# This command actually allocates memory, so this much
# memory must be available.
echo 20 > /proc/sys/vm/nr_hugepages

# Set the group number that is permitted to access this
# memory (102 in this case). The mysql user must be a
# member of this group.
echo 102 > /proc/sys/vm/hugetlb_shm_group

# Increase the amount of shmem permitted per segment
# (12G in this case).
echo 1560281088 > /proc/sys/kernel/shmmax

# Increase total amount of shared memory.  The value
# is the number of pages. At 4KB/page, 4194304 = 16GB.
echo 4194304 > /proc/sys/kernel/shmall

对于mysql的使用,最好是shmmax与shmall接近,查看是否配置好

shell> cat /proc/meminfo | grep -i huge
HugePages_Total:      20
HugePages_Free:       20
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       4096 kB
设置mysql用户的memlock limit为unlimited

ulimit -l unlimited

/etc/security/limits.conf

mysql默认情况下是不用大页内存的,要启用在配置文件中添加

[mysqld]

large-pages



你可能感兴趣的:(mysql大页内存的使用)