0

I am using 5.7.37-log MySQL Community Server. my mysqld.cnf looks below:

server_id = 11
log_bin = bin.log
log-bin-index = bin-log.index
binlog_format = row
max_binlog_size = 100M
socket = mysql.sock
expire_logs_days = 1

when i check my logs they keep on growing though i mention them to get expire in 1 day. using expire_logs_days.

With this above config, can i expect the logs be removed automatically or should I again do it manually ? I see some forms saying PURGE BINARY LOGS BEFORE NOW() - INTERVAL 1 DAY; But i dont understand the point in manually running above statement when we already set the config.

Please help me understanding the expiry mechanism of bin logs. As I used expiry after 1 day, does the size of the bin.00001 and bin.0002 etc. will be reduded every day ? or how can i identify that the logs are really expiring.?

attaching screenshot of my generated bin logs.

enter image description here

santhosh
  • 103
  • 4
  • 1
    I would suggest that you take a look at [dba.se] which might be more fitting for your question and is for enthusiastic administrators – djdomi Apr 24 '23 at 16:55
  • I think that it will purge 000001 when the next one starts, namely 000004. Meanwhile, note that 000003 is only 15% 'full' so far. – Rick James Apr 24 '23 at 18:20
  • @RickJames but then i dont see the use of expire_logs_days = 1. it should purge logs after 1 day irrespective of the log size. But I also observed the old log files getting removed when i do mysql restart. but restarting mysql everytime to remove old logs is not a good idea.. – santhosh Apr 25 '23 at 09:07
  • Please report on what happens after the server stays up long enough to exceed 100M in one binlog. – Rick James Apr 25 '23 at 14:49

1 Answers1

1

There is no timer that runs and deletes logs after one day. Log deletion is triggered by log flush events. So that is when a new binlog is generated. If it takes too long on our database and logs are not flushed daily the you could set max-binlog-size to a lower value. Another good option would be to always flush logs as part of your backup strategy.

TZar
  • 46
  • 2