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

View: 16695|Reply: 2

[Source] Solved the issue of "mysql-bin.000001" taking up a large amount of space

[Copy link]
Posted on 2/1/2016 10:40:04 AM | | | |

The servers have been crashing frequently in recent months, resulting in the availability of the Bill Cover not guaranteed. But strangely, when it crashes, the server can connect normally, and Nginx seems to be normal, but PHP-FPM is unresponsive. Later, I accidentally df -h and found that:
rootfs 7.7G 7.7G 0 100% /

The root directory is full! I thought there were too many logs, so I cleaned up the logs. But basically every Sunday will be full. It makes Bill Gazi restless. Later, /var was partitioned independently, but it still didn't work, how much accounted for the number. I've also cleaned up /var/tmp and /var/cache, but the effect is still limited.

Today, the persistent sub-du -ah, found that /var/lib/mysql occupies an abnormal space, and after cd to ls -lh here, it finds:
-rw-rw---- 1 mysql mysql 5242880 Feb 27 14:49 ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 Dec 27 17:55 ib_logfile1
-rw-rw---- 1 mysql mysql 588M Mar 12 02:03 maria_log.00000003
-rw-rw---- 1 mysql mysql 52 Mar 12 01:54 maria_log_control
drwx------ 2 mysql root 4.0K Jan 15 14:28 mysql
-rw-rw---- 1 mysql mysql 20K Dec 27 17:54 mysqld-bin.000001
-rw-rw---- 1 mysql mysql 715K Dec 27 17:54 mysqld-bin.000002
-rw-rw---- 1 mysql mysql 625 Dec 28 11:46 mysqld-bin.000003
-rw-rw---- 1 mysql mysql 125 Dec 27 18:20 mysqld-bin.000004
-rw-rw---- 1 mysql mysql 125 Dec 27 18:20 mysqld-bin.000005
-rw-rw---- 1 mysql mysql 125 Dec 27 18:21 mysqld-bin.000006
-rw-rw---- 1 mysql mysql 125 Dec 27 18:21 mysqld-bin.000007
-rw-rw---- 1 mysql mysql 125 Dec 27 18:22 mysqld-bin.000008
-rw-rw---- 1 mysql mysql 125 Dec 27 18:22 mysqld-bin.000009
-rw-rw---- 1 mysql mysql 20K Dec 27 18:22 mysqld-bin.000010
-rw-rw---- 1 mysql mysql 715K Dec 27 18:22 mysqld-bin.000011
-rw-rw---- 1 mysql mysql 125 Dec 27 18:24 mysqld-bin.000012
-rw-rw---- 1 mysql mysql 125 Dec 27 18:25 mysqld-bin.000013
-rw-rw---- 1 mysql mysql 125 Dec 27 18:27 mysqld-bin.000014
-rw-rw---- 1 mysql mysql 125 Dec 28 09:55 mysqld-bin.000015
-rw-rw---- 1 mysql mysql 125 Dec 28 11:41 mysqld-bin.000016
-rw-rw---- 1 mysql mysql 125 Dec 28 11:42 mysqld-bin.000017
-rw-rw---- 1 mysql mysql 125 Dec 28 12:07 mysqld-bin.000018
-rw-rw---- 1 mysql mysql 1.4K Dec 28 12:49 mysqld-bin.000019
-rw-rw---- 1 mysql mysql 125 Dec 28 16:31 mysqld-bin.000020
-rw-rw---- 1 mysql mysql 107M Dec 28 18:30 mysqld-bin.000021
-rw-rw---- 1 mysql mysql 1.2M Dec 30 09:22 mysqld-bin.000022
-rw-rw---- 1 mysql mysql 125 Dec 30 09:26 mysqld-bin.000023
-rw-rw---- 1 mysql mysql 3.8K Dec 30 12:29 mysqld-bin.000024
-rw-rw---- 1 mysql mysql 59M Jan 11 21:34 mysqld-bin.000025
-rw-rw---- 1 mysql mysql 10M Jan 14 15:16 mysqld-bin.000026
-rw-rw---- 1 mysql mysql 186K Jan 15 05:16 mysqld-bin.000027
-rw-rw---- 1 mysql mysql 21K Jan 15 14:46 mysqld-bin.000028
-rw-rw---- 1 mysql mysql 13K Jan 15 15:12 mysqld-bin.000029
-rw-rw---- 1 mysql mysql 62M Jan 17 16:36 mysqld-bin.000030
-rw-rw---- 1 mysql mysql 63M Jan 18 17:10 mysqld-bin.000031
-rw-rw---- 1 mysql mysql 125 Jan 18 17:16 mysqld-bin.000032
-rw-rw---- 1 mysql mysql 21K Jan 18 17:23 mysqld-bin.000033
-rw-rw---- 1 mysql mysql 118M Jan 22 12:41 mysqld-bin.000034
-rw-rw---- 1 mysql mysql 209K Jan 22 12:59 mysqld-bin.000035
-rw-rw---- 1 mysql mysql 117M Jan 28 11:59 mysqld-bin.000036
-rw-rw---- 1 mysql mysql 125 Jan 28 13:46 mysqld-bin.000037
-rw-rw---- 1 mysql mysql 24M Jan 28 16:01 mysqld-bin.000038
-rw-rw---- 1 mysql mysql 460K Jan 28 16:10 mysqld-bin.000039
-rw-rw---- 1 mysql mysql 7.0M Jan 28 16:52 mysqld-bin.000040
-rw-rw---- 1 mysql mysql 2.3M Jan 28 17:12 mysqld-bin.000041
-rw-rw---- 1 mysql mysql 2.1M Jan 28 17:27 mysqld-bin.000042
-rw-rw---- 1 mysql mysql 173K Jan 28 17:37 mysqld-bin.000043
-rw-rw---- 1 mysql mysql 378K Jan 28 17:44 mysqld-bin.000044
-rw-rw---- 1 mysql mysql 79K Jan 28 17:50 mysqld-bin.000045
-rw-rw---- 1 mysql mysql 272K Jan 28 18:12 mysqld-bin.000046
-rw-rw---- 1 mysql mysql 156K Jan 28 18:15 mysqld-bin.000047
-rw-rw---- 1 mysql mysql 962K Jan 28 18:33 mysqld-bin.000048
-rw-rw---- 1 mysql mysql 43K Jan 28 18:40 mysqld-bin.000049
-rw-rw---- 1 mysql mysql 28M Jan 29 11:43 mysqld-bin.000050
-rw-rw---- 1 mysql mysql 125 Jan 29 11:46 mysqld-bin.000051
-rw-rw---- 1 mysql mysql 139K Jan 29 12:37 mysqld-bin.000052
-rw-rw---- 1 mysql mysql 135K Jan 29 12:44 mysqld-bin.000053
-rw-rw---- 1 mysql mysql 409M Feb 9 23:18 mysqld-bin.000054
-rw-rw---- 1 mysql mysql 482M Feb 17 09:37 mysqld-bin.000055
-rw-rw---- 1 mysql mysql 542M Feb 27 12:30 mysqld-bin.000056
-rw-rw---- 1 mysql mysql 125 Feb 27 12:31 mysqld-bin.000057
-rw-rw---- 1 mysql mysql 125 Feb 27 14:48 mysqld-bin.000058
-rw-rw---- 1 mysql mysql 854M Mar 13 12:08 mysqld-bin.000059
-rw-rw---- 1 mysql mysql 1.1K Feb 27 14:49 mysqld-bin.index

God, what are these logs and bins?! Finally found the information:
mysql-bin.000001, mysql-bin.000002 and other files are the operation logs of the database, such as UPDATE a table, or DELETE some data, even if the statement does not match the data, this command will be stored in the log file, including the execution time of each statement, will also be recorded. This is primarily for operational review and multi-database synchronization. ib_logfile is used to record InnoDB's table consistency and only works after a crash. maria_log.00000003 is a MariaDB-specific file used by Bill Gai, and it does a similar job.

But for Bill Cover, there is no master-slave database, no review operations, and these files are completely useless! So, clean up these files first. Then edit the mysql configuration file, organize it to record these logs,Shovel weeds and remove roots. Gentoo's MySQL logs are at /etc/mysql/my.cnf. Comment out the log-bin line inside.

Then restart the MySQL server, and the problem is solved! Instantly increase the number of GB of available space!




Previous:Use Alibaba Cloud Host The database often hangs up!
Next:Linux system checks disk space occupied by those large files
 Landlord| Posted on 9/6/2017 1:45:31 PM |
How do I delete the mysql-bin.0000X log file?


In fact, the key command is reset master; This command empties the mysql-bin file.

In addition, if your mysql server does not need master-slave copying, it is recommended to modify the my.cnf file to set these files not to be generated.OnlyDelete or commentmy.cnfThat's it.

log-bin=mysql-bin
If you need to replicate, it is best to control the number of days these log files are retained, and you can set the number of days the log files are retained through the following configuration:

expire_logs_days = 7
Indicates that the logs are kept for 7 days, so that the old logs will be automatically cleaned up.

 Landlord| Posted on 9/14/2024 9:48:14 AM |
MySQL database /var/lib/mysql/ binlog takes up space
https://www.itsvse.com/thread-10831-1-1.html
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