[Reprint]mysql's Binlog safely removed

Source: Internet
Author: User

[Reprint]mysql's Binlog safely removed
Theoretically, you should add a configuration entry for the Binlog expiration time in the profile/etc/my.cnf, Expire_logs_days = 10 but without adding this, the disk is eaten a lot as more and more binlog are generated. You can delete the Binlog file directly, but you can remove it more safely through the tools provided by MySQL. The Mysql-bin.index file is not updated because purge updates the entries in the Mysql-bin.index and deletes them directly. Mysql-bin.index's role is to speed up the search for binlog files. Help me first.:mysql> help purgename: ' PURGE master LOGS ' Description:Syntax:PURGE {master | BINARY} LOGS to ' Log_name ' PURGE {MASTER | binary} LOGS before ' Date ' deletes all the binary LOGS listed in the log index prior to thespecified log or date. The logs also is removed from the list Recordedin the log index file and so, the given log becomes the first. This statement have no effect if the--log-bin option has not beenenabled. Url:http://dev.mysql.com/doc/refman/5.0/en/purge-master-logs.htmlexamples:purge master logs to ' mysql-bin.010 '; PURGE MASTER LOGS before ' 2003-04-02 22:46:26 ';  two ways are available. The first one is to delete to a file, and the second is to delete it to a certain date. For example, we let it keep log for nearly 3 days, so purge MASTER LOGS before ' 2010-10-17 00:00:00 ';  to see the number of files before and after execution: part2# ls mysql-bin.*|wc-l      243 ExecutionPurge:mysql> purge MASTER LOGS before ' 2010-10-17 00:00:00 '; Query OK, 0 rows affected (0.02 sec) after execution: part2# ls mysql-bin.* | wc-l      88 can be seen in the 17th before the Binlog all deleted.   NOTE: It is best to slave up to see the current sync to that Binlog file, with show slave status View. Otherwise, if the master is deleted more, it causes the slave missing log file to cause the data to be inconsistent.

From for notes (Wiz)

[Reprint]mysql's Binlog safely removed

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.