Mysql's binlog is too large to occupy a large number of disks

Source: Internet
Author: User

Phenomenon: Website access is getting slower and slower, and the website cannot be accessed at last. After checking, it is found that the disk is full. After careful query, it is confirmed that the binlog of mysql is too large to occupy space.

Analysis process and solution: Generally, this problem occurs when you log on to the server to check disk, memory, and process usage. top, df-h, and free-m are used to check, it is found that the disk space is full. Run the du-sh command to check the available directories and find that the binlog of mysql occupies too much space. The method for clearing binlog is as follows:

1) set Log retention period expire_logs_days to automatically delete

View the number of days for saving the current log:

Show variables like '% expire_logs_days % ';

The default value is 0, indicating that logs does not expire. You can set a global parameter to make it take effect temporarily:

Set global expire_logs_days = 7;

If BINLOG is set to be retained for only 7 days, the next restart of mysql will fail by default, so you need to set it in my. cnf

Expire_logs_days = 7

2) manually delete BINLOG (purge binary logs)

Deletes all binary logs listed in the log index before the specified log or date. These logs are also recorded in 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 '2017-06-22 13:00:00 ';

Purge master logs before DATE_SUB (NOW (), INTERVAL 3 DAY );

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.