博客

糟糕,我刪除了MySQL二進制日誌

有時候,我們會因為漫長的一天而精疲力盡,最終會犯下錯誤,最終會花費整個團隊很多時間。

Yesterday, I was testing various backup and recovery methods supported by ZRM, a MySQL backup service for an upcoming release. 適用於MySQL的ZRM requires binary logging to be enabled on the MySQL server. I ran out of disk space during testing and removed the binary logs.

偶然地,我刪除了MySQL服務器使用的最後一個二進制日誌,而MySQL服務器使用最新的二進制日誌來運行其守護進程。

Short version - I could not start MySQL server at all.

恢復MySQL二進制日誌:嘗試啟動服務器時的堆棧跟踪

$service mysqld啟動

061031 17:38:48 mysqld已啟動

061031 17:38:48 InnoDB:已啟動;日誌序列號14 1645228884

/usr/libexec/mysqld: File '/var/lib/mysql/mysql-bin.000017' not found (Errcode: 2)

061031 17:38:48 [ERROR] Failed to open log (file '/var/lib/mysql/mysql-bin.000017', errno 2)

061031 17:38:48 [ERROR]無法打開日誌文件

061031 17:38:48 [ERROR] Can't init tc log

061031 17:38:48 [ERROR]中止

061031 17:38:48 InnoDB: Starting shutdown...

061031 17:38:51 InnoDB:關閉已完成;日誌序列號14 1645228884

061031 17:38:51 [注意] / usr / libexec / mysqld:關閉完成

061031 17:38:51 mysqld結束

感謝Aishwarya給我有關如何解決問題的想法。二進制日誌索引文件(/var/lib/mysql/mysql-bin.index)存儲有關最新二進制日誌文件的信息。刪除索引文件即可解決該問題。當然,我使用MySQL的ZRM備份了數據庫,並且可以恢復到刪除二進制日誌之前的任何時間點。

Bottom line: Do not delete the most recent binary log file to save disk space and do regular backups.  ZRM is preferred and here’s a 鏈接 想要查詢更多的信息

發表評論

zh_TWChinese
en_USEnglish fr_FRFrench it_ITItalian es_ESSpanish de_DEGerman pt_BRPortuguese sv_SESwedish tr_TRTurkish nl_NLDutch jaJapanese pl_PLPolish id_IDIndonesian ko_KRKorean ms_MYMalay thThai zh_TWChinese