MySQL Enable SSD storage

Source: Internet
Author: User

MySQL Enable SSD storage Chszs, All rights reserved, without consent, not reproduced. Blogger Home: Http://blog.csdn.net/chszs

Sometimes OS read-write slows down the performance of the MySQL server, especially when the OS uses the same disk as MySQL. So it's best to let MySQL use a separate disk, to use SSDs better. To do this, you need to mount the SSD new disk to the server, assuming the new disk is/dev/sdb.

1. Prepare a new disk:
# fdisk /dev/sdb

Pressing "n" will create a new partition, and pressing "P" will create a new primary partition. Then set the partition number (from 1~4), then select the size of the partition and press ENTER.
If you do not want to use the entire disk as a partition, you will still need to create a new partition.
Press "W" to achieve write changes.

2. Create file system in new partition
# mkfs.ext4 /dev/sdb1
3, the new partition map to a directory, I named "SSD", under the root directory.
# mkdir /ssd/# mount /dev/sdb1 /ssd/
4. Allow this mapping to take effect when the server is started

Modifying a configuration file/etc/fstab

/dev/sdb1 /ssd ext4 defaults 0 0
5. Move MySQL to the new disk

Stop MySQL service first

# service mysqld stop

If the system has a service that writes MySQL, it also stops, such as

# service httpd stop# service nginx stop

Copy the entire MySQL directory to the new disk

# cp /var/lib/mysql /ssd/ -Rp

After the copy is complete, rename the MySQL directory

# mv /var/lib/mysql /var/lib/mysql-backup

Then create a symbolic link

# ln -s /ssd/mysql /var/lib/mysql

Now it's time to start the MySQL service.

# service mysqld start# service httpd start# service nginx start

Copyright NOTICE: This article for Bo Master Chszs original article, without Bo Master permission not reproduced.

MySQL Enable SSD storage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.