今天公司的mysql數據庫出了一些問題,導致我們丟失了一天的數據,這讓我們非常頭疼。我們經過一番排查,分析了原因,希望可以給大家一些啟示。
經過分析,我們發現原因是由于數據庫服務器發生了一次崩潰,然而在這個服務器上的那個磁盤上的日志文件故障。因此,在MySQL實例重啟時,日志文件需要被自動創建,但是由于日志文件在磁盤上故障,MySQL實例重啟時自動創建日志文件失敗,最終導致了數據的遺失。
2021-04-10 02:31:08 109 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace prtb_searches/searches uses space ID: 2 at filepath: ./InnoDB/prtb_searches/searches.ibd. Cannot open tablespace prtb_searches/searches which uses space ID: 2 at filepath: ./InnoDB/prtb_searches/searches.ibd
2021-04-10 02:31:08 7f1c2b2b1770InnoDB: Operating system error number 2 in a file operation.
InnoDB: Error number 2 means 'No such file or directory'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.7/en/operating-system-error-codes.html
2021-04-10 02:31:08 109 [ERROR] InnoDB: Could not find a valid tablespace file for `prtb_searches/searches`. See http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2021-04-10 02:31:08 7f1c2b2b1770InnoDB: Assertion failure in thread 139962746181376 in file fil0fil.cc line 901
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
09:31:08 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
通過這個問題,我們發現在數據庫的運行過程中,數據的安全備份還是十分重要的。我們需要定期備份數據,以防出現類似的異常,可以避免數據的遺失。
總之,雖然這一次的數據丟失帶來了不小的損失,但也給了我們重要的教訓。我們將進一步加強對數據的備份措施,盡可能地保護公司的數據安全。