Because many of the MySQL production environments are under Linux, I decided to point out some important optimizations for Linux running MySQL. This is what everyone knows, and nothing new, but I want to collect and collate Linux-related configuration optimization experiences in this blog.
File system:
Use the Notime option when EXT4 (or XFS) mount
File system scheduling policy: using Deadline or NoOp
# echo Deadline >/sys/block/sda/queue/scheduleradd "Elevator=deadline" to grub.conf |
Translator recommendation: XFS, currently in Red Hat Enterprise 7 after XFS became the default file system.
Memory:
Swappiness and NUMA
Translator Note: It is best to ban swappiness or not use it in the system logo.
# echo 0 >/proc/sys/vm/swappinessadd "vm.swapiness=0" to/etc/sysctl.conf |
Using Numa's Interleave all mode
Numactl–interleave=all Start mysqld
If you use Percona-server in Mysql_safe, there are options for using Numa_interleave. More about information you can view Percona server support for NUMA
(And don't forget to use Innodb_flush_method=o_direct) rformance/innodb_numa_s
Translator Note: Memory optimization This block can be considered using Jemalloc (Tokudb,percona all have to use this way, the official version needs to be self-loaded)
Cpu:
Verify that the low power (powersave) option for the CPU is enabled
Check:
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor |
Verify that the OnDemand is shown here and that the Power saving mode is enabled.
Also check the/proc/cpuinfo and compare the number of CPU MHz to whether the number shown after "model name" is the same
If OnDemand is used, disable him.
For example: "OnDemand" runs on the server:
$ps Ax|grep kondmand|wc-l65$ Cat/sys/devices/system/cpu/cpu0/cpufreq/scaling_governorondemand |
Also see if the CPU's label frequency matches the actual frequency:
/proc/cpuinfo:model Name:intel (R) Xeon (r) CPU e5-4640 0 @ 2.40GHz. CPU mhz:1200.000 |
If not, disable OnDemand (you need to change the configuration in the Bois)
Translator Note: If the CPU exceeds 24 cores, it is recommended to use the later version of MySQL5.6.
Linux optimized for running MySQL "turn"