In one of our environment, we have a Master-Slave replication. A few days ago I discovered that I have a space issue with /var/lib/mysq. As I love to use LVM this should not be a problem at all. I will increase the size of /var/lib/mysql, but… I want to see what makes “problem” on this partition, and here it is. Too many mysql-bin files.
Yes, I forgot to add expire-logs-days=N in [mysqld] section in my.cnf file. So this is a story about the secure way to remove mysql-bin files. On a slave server I have to find up to which mysql-bin file is safe to remove. So, I ‘we run
As we can see Master_Log_File is pointing to mysql-bin.000100 file. It is safe to remove all files UP TO mysql-bin.000100 file
On Master server I had to run this command (I didn't want to make any risk so I' we decided to leave the last bin file)
To avoid this situation, I’ we decide to set global variable (I don’t have to restart MySQL service in this case)
To ensure that I will not forget to add variable in my.cnf on next restart, I have to change my.cnf