当前位置:网站首页>What happens if the MySQL disk is full? I really met you!
What happens if the MySQL disk is full? I really met you!
2022-07-27 09:44:00 【Young】
Use the command to find that the disk utilization rate is 100% 了 , There are dozens of megabytes left .
A series of divine operations
Backup database , Delete the instance 、 Delete database tables 、 restart mysql service , As a result, no disk space was released .
What do I do
I searched a lot of resources on the Internet , Said to do disk defragmentation . as a result of datafree It takes up too much space . You can go through this sql see .
SELECT CONCAT(TRUNCATE(SUM(data_length)/1024/1024,2),'MB') AS data_size,
CONCAT(TRUNCATE(SUM(max_data_length)/1024/1024,2),'MB') AS max_data_size,
CONCAT(TRUNCATE(SUM(data_free)/1024/1024,2),'MB') AS data_free,
CONCAT(TRUNCATE(SUM(index_length)/1024/1024,2),'MB') AS index_size
FROM information_schema.tables WHERE TABLE_NAME = 'datainfo';
This is a later picture , There is no previous picture left , At that time, it showed the data_free All have reached 20 individual G.

Online recommendations are as follows , Break up the forms .
ALTER TABLE datainfo ENGINE=InnoDB;
ANALYZE TABLE datainfo;
optimize table datainfo;
deadlock :
View the database version as 5.562 I won't support it inodb, Or choose to upgrade the database . Just then , There's bad news , The form has been deleted , But the disk space still hasn't been released . So the way to defragment your tables is not going to work , Because the watch is gone ...
Later, the divine operation
1、 Command view mysql The location of the installation and the location of the configuration file
mysql 1118 945 0 14:28 ? 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
2、 close mysql
service mysql stop
3、 Delete datadir In the catalog ibdata1、ib_logfile0 ib_logfile1 These documents

4、 Move mysql Start parameter of
mv /etc/my.cnf ./abc
5、 Restart mysql Found disk space free service mysql start
The disk space is finally free
The next step is to restore the database
1、 use navicate Backup tools , Database backup

After the backup was successful , Generate psc file .200409141055.psc
2、 Create a new database instance , Set database name and character set 
3、 Then restore the backup database , Click restore 
4、 Start restoring After the first restore, we found that the database tables were successfully created after the restore , But there's no data in the table . Later, I searched the Internet and found that it was , Stop when you make a mistake . So the restored configuration was changed , Restore again . It was set up like this before 
Restore as a transaction , Stop when you make a mistake . Change configuration
Restore again , The data in the database has , And verify that there is no problem .
Problem solving
mysql The cause of fragmentation
(1) The storage of the table will be fragmented , Whenever a line is deleted , The space will be left blank , And in a period of time a large number of delete operations , This will make the empty space larger than the space used to store the contents of the list ;
(2) When the insert operation is performed ,MySQL Will try to use blank space , But if a blank space has not been occupied by data of the right size , It still can't be completely occupied , It's a fragment ;
(3) When MySQL When scanning data , The object it scans is actually the upper limit of the list's capacity requirement , That is, the part of the area where the data is written to the peak position ;
The advantages of debris removal :
Reduce the access to the table IO, Improve mysql performance , Free up table space and reduce disk space utilization
Be careful
1.MySQL The official advice is not to ( Every hour or every day ) Defragment , Generally according to the actual situation , Just do it weekly or monthly ( We are in the early hours of every month 4 Spot cleaning mysql Table fragments under all instances ).
2. stay OPTIMIZE TABLE In operation ,MySQL Will lock the table . therefore , This operation must be carried out at a time when the website is less visited .
3. clear student Of 105 Ten thousand data , OPTIMIZE TABLE library .student; Local testing requires 37 second .
Self testing
You can use this sentence to see your own system of datafree big show table status from Table name ;
边栏推荐
- Come on, chengxujun
- Easy to understand! Graphic go synergy principle and Practice
- July training (day 15) - depth first search
- System parameter constant table of system architecture:
- NCCL (NVIDIA Collective Communications Library)
- 系统架构之系统参数常量表:
- [Wuhan University of technology] information sharing for the preliminary and second examinations of postgraduate entrance examination
- I haven't delivered books for a long time, and I feel uncomfortable all over
- QT | about the problem that QT creator cannot open the project and compile it
- 注解与反射
猜你喜欢

Understand chisel language. 23. Chisel sequential circuit (III) -- detailed explanation of chisel shift register

Eureka delayed registration of a pit

食品安全 | 菜板环境很重要,这些使用细节你知道吗?

Quickly apply JS to customize the effect of lunar phase change

吃透Chisel语言.23.Chisel时序电路(三)——Chisel移位寄存器(Shift Register)详解

习题 --- 快排、归并、浮点数二分

都什么年代了你还在用 Date

命令提示符启动不了mysql,提示发生系统错误 5。拒绝访问。解决办法

如何在树莓派上安装cpolar内网穿透

Expose a technology boss from a poor family
随机推荐
July training (day 18) - tree
走向人生巅峰....
Meeting seating function of conference OA project & Implementation of meeting submission for approval
Binary tree traversal
Exercises --- quick arrangement, merging, floating point number dichotomy
July training (day 11) - matrix
How to install cpolar intranet penetration on raspberry pie
吃透Chisel语言.26.Chisel进阶之输入信号处理(二)——多数表决器滤波、函数抽象和异步复位
注解与反射
npm常用命令
I grabbed a ticket and thought I found the system bug of 12306
食品安全 | 菜板环境很重要,这些使用细节你知道吗?
July training (day 20) - binary search tree
如何使用TDengine Sink Connector?
九种方式,教你读取 resources 目录下的文件路径
Nacos配置中心动态刷新数据源
Qt | 关于Qt Creator打开项目编译不过的问题
swagger-editor
In depth analysis, sub database and sub table are the most powerful auxiliary sharding sphere
七月集训(第13天) —— 双向链表