MySQL Server SWAP usage is high, which causes db to be very slow and slow. mysqlswap
High usage of MySQL Server SWAP causes slow db
Environment Introduction:
CentOS: 6.X
MySQL version: 5.5.40
Fault Cause Analysis:
The physical memory is 16 GB, And the swap is 4 GB. MySQL occupies 14 GB of physical memory, while other applications or system processes require 3 GB of memory, at this time, the operating system may map some address spaces owned by MySQL to swap, which may generate swap operation events:
Main causes:
1. mysqldump and mysql import large databases or tables;
2. io writer and io read operations for a large number of concurrent operations at the database layer;
3. copy a large file on the OS layer, such as a database backup file of hundreds of GB.
Common solution:
1. Release SWAP space
# Swapoff-
Then enable swapon
# Swapon-
2. Add the MySQL Configuration Parameter memlock.
This parameter forces the address space of the mysqld process to be locked in the physical memory.
Set max locked memory
# Echo "mysql hard memlock unlimited">/etc/security/limits. conf
# Echo "mysql soft memlock unlimited">/etc/security/limits. conf
3. Modify Kernel Parameters
# Echo "vm. swappiness = 0">/etc/sysctl. conf
4. Modify the parameters of my. cnf:
Modify the innodb_flush_method parameter in my. cnf to enable the O_DIRECT mode.
5. Use the large page memory.
Reference: http://blog.csdn.net/jacson_bai/article/details/44755109