I have started binary logging on MySQL server on my Ubuntu. It start creating log files in /var/log/mysql. My my.cnf configuration is as follows:
log-bin="/var/log/mysql/"
expire_logs_days=10
max_binlog_size=50M
binlog-ignore-db="phpmyadmin"
Problem:
When I check logs folder a new file appears daily. Which is created at around 6:45AM to 7:00AM IST i.e 1:30AM to 1:45 GMT. But According to official documentation of MySQL on Binary Logging says:
The server creates a new file in the series each time it starts or flushes the logs. The server also creates a new binary log file automatically after the current log's size reaches max_binlog_size.
Why new log file is created daily as:
- My system is not rebooted from last 10days which I checked with uptime command in terminal.
- The max_binlog_size is given 50M in configuration and my logs reached only 2-3M.
- I have not used FLUSH logs.
- I have no CRON which do some task auto magically.
I have googled this query but didn't find the reason.
Can anyone help me to know the reason. Thanks in advance
1 Answer 1
4. I have no CRON which do some task auto magically
I'll speculate that you actually do. Linux systems often use the logrotate
utility to manage rotation of log files from numerous disparate subsystems.
Distro builders love to coerce software installed from packages to Do Things The One True WayTM so it should not surprise you if they have "extended" MySQL server beyond the official documentation, to rotate its own binlog.
You may find syslog entries mentioning "logrotate" around the time that the binlog changes, and further explanation is likely to be found in a file somewhere around here:
/etc/logrotate.d/mysql-server
-
I want to disable logrotate. will it effect my other applications Logs?عثمان غني– عثمان غني2014年02月13日 13:28:51 +00:00Commented Feb 13, 2014 at 13:28
-
I'm not suggesting that you disable logrotate... just pointing you in the direction of what I suspect is rotating your binlogs unexpectedly. You should be able to simply comment-out everything in the
mysql-server
file to stop the behavior... but there's not really a disadvantage to letting it rotate your binlogs every day. Storing the same events in one log vs multiple logs will only result in a very tiny increase in storage space required, since the binlog format is generally very efficient.Michael - sqlbot– Michael - sqlbot2014年02月13日 14:21:53 +00:00Commented Feb 13, 2014 at 14:21 -
As I am going to make an Automatic Backup script. So I need to FLUSH logs when backup script will run. What is the method to stop log rotate? (As I know to remove it from cron.daily but is there any other way?)عثمان غني– عثمان غني2014年02月14日 04:19:34 +00:00Commented Feb 14, 2014 at 4:19
-
My backup script uses "mysqldump --flush-logs", so I commented out the line with "$MYADMIN flush-logs" in file /etc/logrotate.d/mysql-server. Now I get a fresh log file when I backup or restart mysqlropo– ropo2017年02月22日 09:10:56 +00:00Commented Feb 22, 2017 at 9:10