Enable SSD storage in MySQL, and enable ssd in mysql
Author of enabling SSD storage in MySQL: chszs. All Rights Reserved. It cannot be reproduced without consent. Blogger home: http://blog.csdn.net/chszs
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 need to 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 /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
Copyright Disclaimer: This article is the original article of the blogger chszs and cannot be reproduced without the permission of the blogger.