Sometimes the read/write speed of the OS reduces the performance of the MySQL server, especially when the OS and MySQL use the same disk. Therefore, it is better to make MySQL use a separate disk and use SSD. To achieve
Sometimes the read/write speed of the OS reduces the performance of the MySQL server, especially when the OS and MySQL use the same disk. Therefore, it is better to make MySQL use a separate disk and use SSD. To achieve
Sometimes the read/write speed of the OS reduces the performance of the MySQL server, especially when the OS and MySQL use the same disk. Therefore, it is better to make MySQL use a separate disk and use SSD. To do this, you need to mount the new SSD disk to the server, assuming that the new disk is in/dev/sdb.
1. Prepare a new disk:
# Fdisk/dev/sdb
Press "n" to create a new partition, and press "p" to create a new primary partition. Then set the Partition Number (from 1 ~ 4), select the partition size, and press the Enter key.
If you do not want to use the entire disk as a partition, you must create a new partition.
Press "w" to implement write change.
2. Create a file system in the new partition
# Mkfs. ext4/dev/sdb1
3. Map the new partition to a directory. I named it "ssd" under the root directory.
# Mkdir/ssd/
# Mount/dev/sdb1/ssd/
4. Make the ing take effect at server startup
Modify the configuration file/etc/fstab
/Dev/sdb1/ssd ext4 defaults 0 0
5. Move MySQL to a new disk
Stop MySQL service first
# Service mysqld stop
If the system has a service that writes MySQL, it also stops, for example
# Service httpd stop
# Service nginx stop
Copy the entire MySQL directory to the new disk.
# Cp/var/lib/mysql/ssd/-Rp
After copying, rename the MySQL directory
# Mv/var/lib/mysql-backup
Create a symbolic link
# Ln-s/ssd/mysql/var/lib/mysql
Now you can start the MySQL service.
# Service mysqld start
# Service httpd start
# Service nginx start
This article permanently updates the link address: