How to clean up Alibaba Cloud MySQL space

How to clean up Alibaba Cloud MySQL space

Today I received a disk warning notification from Alibaba Cloud. I checked and found that 80G of the 100G space had been used. If I decide to delete the data before January 1, 2018, I will find that the available disk space has not decreased after deletion, but has increased rapidly. This made me very anxious, and the database was locked soon.

I quickly searched Baidu and found out that after deleting, the disk would not be reduced, and I had to execute OPTIMIZE TABLE +表名. Later, I found a savior, but the command failed. It turned out that there was insufficient space. The database was locked and this command could not be executed. I was at a loss and decided to pause the server first. Just when it was paused, a miracle happened. There was more than 5G of available space, so I could execute OPTIMIZE TABLE to optimize the table. However, after 3 minutes of execution, the command returned an error. I saw that there was insufficient space again and the table was locked again.

The final decision was to export a table and transfer it to a sql file. It took 40 minutes to complete the export. Then I deleted the table. The server suddenly had 50G more available space. So I ran the sql file again to restore the data, which took a full 150 minutes. After the execution, 70G of disk space was used. Then OPTIMIZE TABLE +表名was executed. Because one of the tables was too large, it took nearly 40 minutes to execute. During this period, the disk usage rate once soared to 100%, but fortunately it just passed.

After deleting data, the MySQL space will not be reduced. You need to execute OPTIMIZE TABLE . OPTIMIZE TABLE will generate a large number of temporary files. If the original table is large, it will take up a lot of space. Therefore, when executing this command, make sure there is enough disk space. Otherwise, executing other operations may cause insufficient disk space, lock the database, and cause execution failure.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Several specific methods of Mysql space cleaning

<<:  Navicat cannot create function solution sharing

>>:  Native JS to implement click number game

Recommend

Analysis of MySQL example DTID master-slave principle

Table of contents 1. Basic Concepts of GTID 2. GT...

Docker meets Intellij IDEA, Java development improves productivity tenfold

Table of contents 1. Preparation before developme...

Mysql sorting and paging (order by & limit) and existing pitfalls

Sorting query (order by) In e-commerce: We want t...

JavaScript implements password box verification information

This article example shares the specific code of ...

How to fix some content in a fixed position when scrolling HTML page

This article mainly introduces how some content i...

When to use Map instead of plain JS objects

Table of contents 1. Map accepts any type of key ...

Use Element+vue to implement start and end time limits

This article example shares the specific code for...

Upgrade Docker version of MySQL 5.7 to MySQL 8.0.13, data migration

Table of contents 1. Back up the old MySQL5.7 dat...

Web Design Help: Web Font Size Data Reference

<br />The content is reproduced from the Int...

In-depth analysis of MySQL 8.0 redo log

Table of contents Preface Generation of redo log ...

MAC+PyCharm+Flask+Vue.js build system

Table of contents Configure node.js+nvm+npm npm s...

Neon light effects implemented with pure CSS3

This is the effect to be achieved: You can see th...

Summary of four situations of joint query between two tables in Mysql

Generally speaking, in order to get more complete...