Detailed explanation of MySQL instance with SSD storage enabled

Detailed explanation of MySQL instance with SSD storage enabled

Detailed explanation of MySQL instance with SSD storage enabled

Sometimes slow OS read and write operations can degrade MySQL server performance, especially when the OS and MySQL use the same disk. Therefore, it is best to let MySQL use a separate disk, preferably an SSD. To do this, you need to mount the new SSD disk to the server, assuming the new disk is at /dev/sdb.

1. Prepare a new disk:

# fdisk /dev/sdb

Pressing 'n' will create a new partition; pressing 'p' will create a new primary partition. Then set the partition number (from 1 to 4), select the partition size, and press Enter.

If you do not want to use the entire disk as a partition, you still need to continue creating new partitions.

Press "w" to write the changes.

2. Create a file system on a new partition

# mkfs.ext4 /dev/sdb1

3. Map the new partition to a directory. I named it "ssd" in the root directory.

# mkdir /ssd/
# mount /dev/sdb1 /ssd/

4. Make this mapping effective when the server starts

Modify the configuration file /etc/fstab

/dev/sdb1 /ssd ext4 defaults 0 0

5. Move MySQL to the new disk

Stop the MySQL service first

# service mysqld stop

If the system has a MySQL service, stop it, for example

# 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

Next, 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

If you have any questions, please leave a message or come to the community to discuss. Thank you for reading and I hope it can help you. Thank you for your support of this site!

You may also be interested in:
  • MySQL performance optimization best 20 experience sharing
  • In-depth analysis of MySQL database engine introduction, differences, creation and performance testing
  • MYSQL performance optimization sharing (sharding of databases and tables)
  • MySQL performance optimization road --- modify the configuration file my.cnf
  • MySQL Performance Settings
  • Tips to significantly improve MySQL query performance
  • MySQL performance optimization index optimization
  • Detailed analysis and testing of SSD performance issues in MySQL servers

<<:  React sample code to implement automatic browser refresh

>>:  Detailed configuration of wireless network card under Ubuntu Server

Recommend

MySQL joint index effective conditions and index invalid conditions

Table of contents 1. Conditions for joint index f...

The most common mistakes in HTML tag writing

We better start paying attention, because HTML Po...

Detailed installation and configuration tutorial of MySQL 5.7 under Win10

1. Unzip MySQL 5.7 2. Create a new configuration ...

Detailed explanation of MySQL from getting started to giving up - installation

What you will learn 1. Software installation and ...

Introduction to major browsers and their kernels

Trident core: IE, MaxThon, TT, The World, 360, So...

Input file custom button beautification (demo)

I have written such an article before, but I used...

What we have to say about CSS absolute and relative

Written in the opening: Absolute said: "Rela...

VMware installation of Ubuntu 20.04 operating system tutorial diagram

Memo: Just experience it. Record: NO.209 This exa...

Implementation of Docker container state conversion

A docker container state transition diagram Secon...

Vue implements a simple shopping cart example

This article example shares the specific code of ...

js to achieve simple drag effect

This article shares the specific code of js to ac...