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

The specific use and difference between attribute and property in Vue

Table of contents As attribute and property value...

jQuery realizes the effect of theater seat selection and reservation

jQuery realizes the effect of theater seat select...

Detailed explanation of Vue's ref attribute

Summarize This article ends here. I hope it can b...

Zookeeper unauthorized access test problem

Table of contents Preface Detect Zookeeper servic...

How to implement remote automatic backup of MongoDB in Linux

Preface After reading the previous article about ...

jQuery implements simple pop-up window effect

This article shares the specific code of jQuery t...

Detailed explanation of Linux file operation knowledge points

Related system calls for file operations create i...

I have sorted out some domestic design websites that I think are good.

<br />I have compiled some domestic design w...

In-depth analysis of MySQL indexes

Preface We know that index selection is the work ...

Sample code for implementing neon button animation effects with CSS3.0

Today I will share with you a neon button animati...

How to encapsulate timer components in Vue3

background When you open the product details on s...

Vue parent component calls child component function implementation

Vue parent component calls the function of the ch...

Solution to the failure of 6ull to load the Linux driver module

Table of contents 0x01 Failed to load the driver ...

Six weird and useful things about JavaScript

Table of contents 1. Deconstruction Tips 2. Digit...