Enable SSD storage in MySQL, and enable ssd in mysql

Source: Internet
Author: User

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.

Related Article

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.