MySQL's binlog is too big and too much for a lot of disk to solve

Source: Internet
Author: User

Phenomenon: Web site access more and more slow, and finally inaccessible, after the check found that the disk is full. Careful inquiry down to confirm is because the binlog of MySQL too much occupied space.

Analysis process and solution: Usually this problem should be logged in to the server to check the disk, memory and process use, through the top, df–h and free–m to check, found that disk space is full. Further through the du–sh to the directory can be checked, found that the MySQL binlog occupy too much space. The way to clean the Binlog is as follows:

1 set log retention time long expire_logs_days automatic deletion

To view the current log save days:

Show variables like '%expire_logs_days% ';

This default is 0, that is, logs, you can set the global parameters to enable him to take effect temporarily:

Set global expire_logs_days=7;

Set to keep only 7 days binlog, next restart mysql This parameter defaults will fail, so you need to set up in MY.CNF

Expire_logs_days = 7

2) manually delete binlog (purge binary logs)

Used to delete all binary logs that are listed in the log index before the specified log or date. These logs will also be recorded from the log index file

PURGE {MASTER | BINARY} LOGS to ' Log_name '

PURGE {MASTER | BINARY} LOGS before ' date '

For example:

PURGE MASTER LOGS to ' mysql-bin.010 ';

PURGE MASTER LOGS before ' 2008-06-22 13:00:00 ';

PURGE MASTER LOGS before Date_sub (now (), INTERVAL 3 day);

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.