MySQL資料的binlog處理方法

來源:互聯網
上載者:User

MySQL資料的binlog處理方法

最近磁碟增長的非常快,發現binlog日誌佔用很大的磁碟資源。我們採用手動清理,後面設定一下自動清理。

查看指定刪除日誌

mysql >show binary logs; 查看多少binlog日誌,佔用多少空間。

mysql> PURGE MASTER LOGS TO 'mysql-bin.002467'; 刪除mysql-bin.002467以前所有binlog,這樣刪除可以保證*.index資訊與binlog檔案同步。

 

手動清理

mysql>PURGE MASTER LOGS BEFORE DATE_SUB(CURRENT_DATE, INTERVAL 5 DAY); 手動刪除5天前的binlog日誌

 

自動化佈建清理

mysql> set global expire_logs_days = 5; 把binlog的到期時間設定為5天;
mysql> flush logs; 刷一下log使上面的設定生效,否則不生效。

為保證在MYSQL重啟後仍然有效,在my.cnf中也加入此參數設定

expire_logs_days = 5

MySQL資料恢複--binlog 

MySQL中binlog日記清理

如何安全刪除MySQL下的binlog日誌

MySQL--binlog日誌恢複資料

MySQL刪除binlog日誌及日誌恢複資料的方法

MySQL binlog三種格式介紹及分析

MySQL 利用binlog增量備份+還原執行個體

MySQL刪除binlog日誌及日誌恢複資料

本文永久更新連結地址:

相關文章

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.