HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

My disk is full of binlog files

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
binlogfullfilesdisk

Problem

I just realized that my server is growing by 2 GB per day, which is not normal.

I looked at my folder and the folder / var / lib / mysql reached 26 GB

Normally it should be about 4 GB

A month ago I migrated my MySQL 5.7 database to MySQL 8.0

I think my disk is full of binlog files.

I would like to know why these files suddenly get bigger ?

How can I fix this without damaging my database ?

```
total 26511376
-rw-r----- 1 mysql mysql 56 Aug 19 2018 auto.cnf
-rw-r----- 1 mysql mysql 178 Mar 10 06:07 binlog.000001
-rw-r----- 1 mysql mysql 73883481 Mar 10 06:25 binlog.000002
-rw-r----- 1 mysql mysql 58601919 Mar 10 13:13 binlog.000003
-rw-r----- 1 mysql mysql 178322334 Mar 11 06:25 binlog.000004
-rw-r----- 1 mysql mysql 379019579 Mar 12 06:25 binlog.000005
-rw-r----- 1 mysql mysql 1075214425 Mar 13 02:10 binlog.000006
-rw-r----- 1 mysql mysql 710899072 Mar 13 06:25 binlog.000007
-rw-r----- 1 mysql mysql 1073746776 Mar 13 20:15 binlog.000008
-rw-r----- 1 mysql mysql 616483095 Mar 14 06:25 binlog.000009
-rw-r----- 1 mysql mysql 1073836859 Mar 15 00:38 binlog.000010
-rw-r----- 1 mysql mysql 1074301774 Mar 15 03:52 binlog.000011
-rw-r----- 1 mysql mysql 1073936970 Mar 15 04:10 binlog.000012
-rw-r----- 1 mysql mysql 1073793229 Mar 15 04:43 binlog.000013
-rw-r----- 1 mysql mysql 324536092 Mar 15 06:25 binlog.000014
-rw-r----- 1 mysql mysql 1074204920 Mar 15 11:00 binlog.000015
-rw-r----- 1 mysql mysql 1074309915 Mar 16 01:10 binlog.000016
-rw-r----- 1 mysql mysql 323166533 Mar 16 06:25 binlog.000017
-rw-r----- 1 mysql mysql 290236337 Mar 16 20:46 binlog.000018
-rw-r----- 1 mysql mysql 236901439 Mar 17 06:25 binlog.000019
-rw-r----- 1 mysql mysql 480168672 Mar 18 06:25 binlog.000020
-rw-r----- 1 mysql mysql 709223503 Mar 19 06:25 binlog.000021
-rw-r----- 1 mysql mysql 1074813984 Mar 19 17:17 binlog.000022
-rw-r----- 1 mysql mysql 1073759979 Mar 20 04:20 binlog.000023
-rw-r----- 1 mysql mysql 272250245 Mar 20 06:25 b

Solution

With MySQL8, they have turned on binary logging by default and the default purge (expiry/deletion) of binary logs is set to 30days.

Once you are in your SSH and in mysql, you can use the below commands

To show binary logs

mysql> SHOW BINARY LOGS;


To Purge binary logs manually until some point

mysql> PURGE BINARY LOGS TO 'binlog.000142';


Change automatic default purge expiry from 30days (deafault) to 3days

mysql> SET GLOBAL binlog_expire_logs_seconds = (60*60*24*3);
Query OK, 0 rows affected (0.00 sec)

mysql> SET PERSIST binlog_expire_logs_seconds = (60*60*24*3);
Query OK, 0 rows affected (0.01 sec)


The above value is in seconds, i.e. 3 days in seconds = (60 seconds x 60 minutes x 24 hours x 3 days)

Code Snippets

mysql> SHOW BINARY LOGS;
mysql> PURGE BINARY LOGS TO 'binlog.000142';
mysql> SET GLOBAL binlog_expire_logs_seconds = (60*60*24*3);
Query OK, 0 rows affected (0.00 sec)

mysql> SET PERSIST binlog_expire_logs_seconds = (60*60*24*3);
Query OK, 0 rows affected (0.01 sec)

Context

StackExchange Database Administrators Q#233048, answer score: 10

Revisions (0)

No revisions yet.