This article is a mirror article of machine translation, please click here to jump to the original article.

View: 2164|Reply: 0

[Source] MySQL database /var/lib/mysql/ binlog takes up space

[Copy link]
Posted on 9/14/2024 9:47:54 AM | | | |
Requirements: The server hard disk is full, and it is found that almost all of them are caused by MySQL binlog occupancy. How to safely clean up and delete binlog files?

Review:

Solved the issue of "mysql-bin.000001" taking up a large amount of space
https://www.itsvse.com/thread-2694-1-1.html

CentOS counts each folder size and looks for large files
https://www.itsvse.com/thread-9542-1-1.html

The server disk space is full, and it is found that the MySQL binlog is occupied, as shown in the figure below:

binlog is a binary log maintained by the Mysql sever layer, which is completely different from the redo/undo log in the innodb engine. It is mainly used to record SQL statements that update or potentially update mysql data, record all DDL and DML (except data query statements) statements, and save them in the form of transactions in disk, and also contain the time consumed by the execution of statements.



Log in to the MySQL database and run the following command to see the current list of binlog files:



Clean up binlog log files to free up space, clean up specified binlog files, and empty all binlog files, with the following commands:



Although this problem has been solved, it may still happen in the future, and we need to set it upexpire_logs_daysto automatically clean up historical binlog files, keeping only files for a certain period of time.

Use mysql --help | grep cnf command query the configuration file as shown in the following image:



Query binlog related configurations via the command line:

revise/etc/my.cnfThe configuration is as follows:

Then restart the mysqld service with the following command:

(End)




Previous:A bug about dotnet-cli publishing the publish project PublishUrl
Next:【Continuous Updates】Discuz X3.4 program optimization and cleaning
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com