# 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 

For MySQL usage, you normally want the value of shmmax  to be close to the value of shmall . 

To verify the large page configuration, check /proc/meminfo  again as described previously. Now you should see some nonzero values: 

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

The final step to make use of the hugetlb_shm_group  is to give the mysql  user an “unlimited”  value for the memlock limit. This can be done either by editing /etc/security/limits.conf  or by adding the following command to your mysqld_safe  script: 

ulimit -l unlimited 

Adding the ulimit  command to mysqld_safe  causes the root  user to set the memlock limit to unlimited  before switching to the mysql  user. (This assumes that mysqld_safe  is started by root .) 

Large page support in MySQL is disabled by default. To enable it, start the server with the --large- pages  option. For example, you can use the following lines in the server my.cnf  file: 

[mysqld] large-pages 

With this option, InnoDB  uses large pages automatically for its buffer pool and additional memory pool. If InnoDB  cannot do this, it falls back to use of traditional memory and writes a warning to the error log: Warning: Using conventional memory pool 

## 8.13 Measuring Performance (Benchmarking) 

To verify that large pages are being used, check /proc/meminfo  again: 

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

To measure performance, consider the following factors: 

