Quote of the day - Simplicity

“We must strive to reach that simplicity that lies beyond sophistication.” –John Gardner

Quote of the day - Being somebody

“I always wanted to be somebody. I should have been more specific.”
– Lily Tomlin

Quote of the day - Time

“Time is the quality of nature that keeps events from happening all at once. Lately it doesn’t seem to be working.”
–Anonymous

How to manage MySQL binary log space (Debian)

So it turns out that what is filling up my root partition is my MySQL binary logs.

A collection of fat files in /var/log/mysql ...

So I had several options:

  • Move the logs to a different partition
  • Increase the size of the root partition
  • Decrease the size of the logs

The first option is probably the most reasonable one. But since I had other plans for the evening I actually went with the last option: decreasing the size of the logs! :roll:

The magic conf is located in /etc/mysql/my.cnf and the magic line is:

Code

expire_logs_days = 5

It was set to 10 but I have no idea why I even need 5 days. Aren't those logs only useful until transactions commit to disk, and replication executes. Oh maybe if you have replicated slaves more than 5 days behind the master??

Edit 2009: You can purge the logs up to a specific file with a statement like this:

Code

PURGE BINARY LOGS TO 'mysql-bin.000666';

Why is my Linux root partition full?

Oh my... nothing puts a server down on its knees more than a root partition with 0% free space. Oh well, ok, maybe being dugg beats it. But still, when you have a full partition, you're in trouble...

First thing is to find what is using that much space. My best bet is to do this:

cd /
du -s *

You may also like du -sh * which will show human readable sizes.

Then you just need to cd into the largest dir and iterate... ;)