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

Implementation of Docker container connection and communication

Port mapping is not the only way to connect Docke...

Analysis and application of irregular picture waterfall flow principle

The layout problem of irregular picture walls enc...

Detailed explanation of asynchronous programming knowledge points in nodejs

Introduction Because JavaScript is single-threade...

Linux Check the installation location of the software simple method

1. Check the software installation path: There is...

Detailed explanation of the solution to font blur when using transform in CSS3

This question is very strange, so I will go strai...

Implementation of nested jump of vue routing view router-view

Table of contents 1. Modify the app.vue page 2. C...

4 ways to optimize MySQL queries for millions of data

Table of contents 1. The reason why the limit is ...

Detailed explanation of Tomcat configuration and optimization solutions

Service.xml The Server.xml configuration file is ...

Complete steps to install boost library under linux

Preface The Boost library is a portable, source-c...

Detailed explanation of MySQL's MERGE storage engine

The MERGE storage engine treats a group of MyISAM...

How to inherit CSS line-height

How is Line-height inherited?Write a specific val...

How to use dynamic parameters and calculated properties in Vue

1. Dynamic parameters Starting from 2.6.0, you ca...

VUE+Canvas realizes the whole process of a simple Gobang game

Preface In terms of layout, Gobang is much simple...

CSS to implement sprites and font icons

Sprites: In the past, each image resource was an ...