The characteristics of the InnoDB engine are like this. The files occupying space are bin-log file (binary log) and ibdata1 (data file, table space is here) There are also some other logs (ib_logfile0) redo-log and undo-log.
If you execute TRUNCATE to delete data, it will not affect (reduce) the size of the above files, but will increase. You must record your TRUNCATE operation. Even if the data is deleted, it will not be deleted in the ibdata1 space, because to delete the data inside, a large amount of disk space needs to be moved. Innodb only marks those data pages that can be used again, and does not delete this space. Usually, once mysql is started, it will occupy several G of ibdata1 and ibdata2. Allocate a large disk first and then use it slowly so that the data is physically continuous (high efficiency). Avoid allocating disk space all the time and creating a lot of fragmentation.
Unless you clear the entire data directory (equivalent to reinstalling mysql) and then re-import the data.
Disks are very cheap, just install a few large disks. There is no disk, so what kind of database can I use?
I don’t understand. But if buying a hard drive can solve the problem, there is no need to think about other solutions. The overall cost of investment is higher, and the occurrence of this situation itself shows that you really need to consider disk space issues, such as disk arrays and data tables. Split, whether redis/memcached is needed to help the database reduce pressure, etc. This is a more important thing.
Recommend, I have encountered it before, and later dealt with it, and wrote a blog http://astarblog.cn/index.php/2016/04/27/339.html (Is this considered an advertisement?)
The characteristics of the InnoDB engine are like this.
The files occupying space are bin-log file (binary log) and ibdata1 (data file, table space is here)
There are also some other logs (ib_logfile0) redo-log and undo-log.
If you execute TRUNCATE to delete data, it will not affect (reduce) the size of the above files, but will increase. You must record your TRUNCATE operation. Even if the data is deleted, it will not be deleted in the ibdata1 space, because to delete the data inside, a large amount of disk space needs to be moved. Innodb only marks those data pages that can be used again, and does not delete this space. Usually, once mysql is started, it will occupy several G of ibdata1 and ibdata2. Allocate a large disk first and then use it slowly so that the data is physically continuous (high efficiency). Avoid allocating disk space all the time and creating a lot of fragmentation.
Unless you clear the entire data directory (equivalent to reinstalling mysql) and then re-import the data.
Disks are very cheap, just install a few large disks. There is no disk, so what kind of database can I use?
I don’t understand. But if buying a hard drive can solve the problem, there is no need to think about other solutions. The overall cost of investment is higher, and the occurrence of this situation itself shows that you really need to consider disk space issues, such as disk arrays and data tables. Split, whether redis/memcached is needed to help the database reduce pressure, etc. This is a more important thing.
Recommend, I have encountered it before, and later dealt with it, and wrote a blog http://astarblog.cn/index.php/2016/04/27/339.html (Is this considered an advertisement?)