I asked this on the MySQL forums, but didn't get any replies:
I've been manually running "PURGE BINARY LOGS TO" to purge the binary logs of a master DB for over a year now (1 slave DB on a different machine). After my most recent purge, over the next few hours, it generated a huge amount of logs - about 8 files of 1 GB each. Normally, it would take days before one 1GB file would be created. I did another purge that day and restarted mysql and it has returned to normal. What could have caused this? Is there anything I should be concerned about right now?
I can't remember the exact number of the purge command and it is now gone from history since I restarted mysql, but I think it was:
PURGE BINARY LOGS TO 'mysql-log.000101';
Thanks for any insight into this.
Related
I have configured the database using SET GLOBAL binlog_expire_logs_seconds = 259200; query to purge binary logs older then 3 days. Using MySQL 8.0.22. This does not seem to have any effect. bin logs are accumulating under /var/lib/mysq/dbname-bin.000xx files. Executing
PURGE BINARY LOGS BEFORE '2020-.......'
works, but I would like the DB engine to purge those logs on its own without myself calling it. Otherwise binlogs take most of the disk space. Please suggest.
I had the same problem (but on Windows 10), I edited my.ini located in c:/xampp/mysql/bin and added the following:
binlog_expire_logs_seconds=60
Does this work for you?
We have noticed that we run out of space on one of our machines that is running Mysql 5.5.37 (InnoDb)
Mysql seems to be generating several ~1.1GB files per day with the name pattern 0.0001234 (increasing number) in the /var/lib/mysql folder.
What are those files?
Can they be deleted?
Can we configure mysql to write them to a different location?
To avoid having to do the purge periodically, set this:
expire_logs_days = 7
in my.cnf. That will keep the binlogs purged down to 7 days' worth.
See also binlog_expire_logs_seconds in MySQL 8.0.
Turns out these were binlogs.
The setting log_bin=0
does not disable them but simply sets the file-name-format to 0.\d+
We deleted the present logs with PURGE BINARY LOGS to 'lastFileName', then disabled the generation by commenting out all bin_log related entries in the my.cnf.
Every night the MySQL database is saved by a cronjob which uses mysqldump.
During the day, when the CakePHP application is running, I would like to have a logfile working, that could be used as backup in case of a damage happening during the day.
For recovery, it would be necessary to first run the recovery from the mysqldump that was established at night. And secondly, run the recovery from the logfile to get the database changes from the current day.
Does there exist such a logfile possibility and where or how could I get it?
Or are there any other ways to get a proper backup?
It's built into MySQL, you wouldn't do this in your applictation typically.
enter link description here
The binlogs do what you say - it is a binary file that contains every transaction that hits the database. So, if you had a nightly back up and the server crashed, you would recover the bin logs, export the transaction logs from the datetime of the last transaction in the database and essentially re-run or re-play every transaction from that point.
And having used it >10 times before ... it is awesome... but you have to turn in on in your my.conf file (google that) and manage the binlog files as they do get big on busy servers.
I had a problem with our InnoDB database. I tried the
innodb_force_recovery = 4
option in /etc/my.cnf
MySQL can't be used but runs at 100% CPU. Is it normal? Does it try to recover, or I waste my time waiting for the process to stop using 100%?
It runs since 17 minutes now, the ibdata1 file is about 6Gb.
Thanks!
Don't stop on innodb_force_recovery = 4 , try values 5 and 6.
Check the error log too. If it prints something like "Waiting to start purge thread" then add innodb_purge_threads=0 to my.cnf
Then dumps all databases with mysqldump and reload into the fresh mysql instance
I have a master and slave database running on different nodes. The master DB is subjected to huge no. of inserts/updates. The master DB size is close to 6 GB, while the log files are now occupying a space of more than 120 GB. I am running out of disk space and need to get rid of the log files.
Will deleting the log files in anyway affect the slave DB ? Presently, the slave is just a couple of seconds behind the master.
Is there someplace where I can see what steps I need to follow to delete those files
eg.
1)Shut down the slave
2)Shut down the master
3)Delete the log files
4)Start the Master
5)Start the Slave
Do I need to inform the slave that the log files have been deleted ?? If yes, what is the way to do it ?
Any help would be appreciated.
Thanks
Yes, you can delete the OLD bin_log files. Make sure they're super old.
Also, I would do mysql flush_logs
You should also set your config file to expire your log files after X days.
This MySql documentation has all the information beautifully laid out
http://dev.mysql.com/doc/refman/4.1/en/purge-binary-logs.html