MySQL Large batch delete log

Source: Internet
Author: User


Today MySQL server disk space exhaustion, after the discovery of MySQL directory generated a large number of binary log files, occupy dozens of g of disk space, almost 3,000 files, such as

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/44/wKioL1V39EagUaejABAKFWxMw_M384.jpg "title=" MySQL binary file. png "alt=" wkiol1v39eaguaejabakfwxmw_m384.jpg "/>

Enter MySQL to view the relevant log settings

mysql> show variables like  '%log% '; +-----------------------------------------+--------- ------------------------------------+| variable_name                             | Value                                         |+-----------------------------------------+------------------------------ ---------------+| back_log                                  | 50                                            | |  binlog_cache_size                        | 32768                                         | |  binlog_direct_non_transactional_updates | OFF                                           | |  binlog_format                            | mixed                                         | |  expire_logs_days                         | 0            #这个默认是0, i.e. logs

This is done by manually deleting these log files and then setting the value of Expire_logs_days, which is automatically deleted for more than 7 days.

Mysql> purge master logs to ' mysql-bin.002970 '; #表示将主库的日志记录清除到以 ' mysql-bin.002970 ' for the beginning of the log.            Query OK, 0 rows affected (1 min 30.29 sec) mysql> set global expire_logs_days=7; #这个是全局变量, restarting MySQL will not take effect. Query OK, 0 rows Affected (0.00 sec)

Another way is to modify the/ETC/MY.CNF, add a line below the mysqld. Restart MySQL for permanent entry, only 7 days of binary logs are reserved.

Expire_logs_days = 7


This article is from the "operations, hello" blog, please be sure to keep this source http://denghaibin.blog.51cto.com/4128215/1660494

MySQL Large batch delete log

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.