Mysql
複製 /var/lib/mysql 文件導致 InnoDB 損壞
我的伺服器昨天必須重新安裝,所以他們更換了硬碟並通過 USB 連接了舊的。我抓取了數據庫文件(/var/lib/mysql)並下載了它們,然後我刪除了本地測試伺服器的所有 db 文件,並將其替換為我的實時伺服器中的文件。
起初一切正常,然後我注意到有幾張桌子顯示為“正在使用”。我發現 InnoDB 工作不正常,最終發現修復方法是刪除 ib_logfile0 和 ib_logfile2 文件。現在我的 MySQL 伺服器無法啟動,並且出現以下錯誤:
110716 10:19:04 mysqld started 110716 10:19:04 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295 110716 10:19:04 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295 InnoDB: The log sequence number in ibdata files does not match InnoDB: the log sequence number in the ib_logfiles! 110716 10:19:04 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Restoring possible half-written data pages from the doublewrite InnoDB: buffer... InnoDB: Database page corruption on disk or a failed InnoDB: file read of page 7. InnoDB: You may have to recover from a backup. 110716 10:19:04 InnoDB: Page dump in ascii and hex (16384 bytes): len 16384; hex 0000000000000000cd12deee693d9fd84ee8bdf2000000070000000000000000000000006935b4760000000000000000000000000000000000000000180000000000000013ee000000000000034f000000000000000d0a00000008000000090000000d0a0000000b0000000c0000$ 110716 10:19:05 InnoDB: Page checksum 3392292161, prior-to-4.0.14-form checksum 3716350408 InnoDB: stored checksum 0, prior-to-4.0.14-form stored checksum 0 InnoDB: Page lsn 1323875826 7, low 4 bytes of lsn at page end 0 InnoDB: Page number (if stored to page already) 0, InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 26933 InnoDB: Database page corruption on disk or a failed InnoDB: file read of page 7. InnoDB: You may have to recover from a backup. InnoDB: It is also possible that your operating InnoDB: system has corrupted its own file cache InnoDB: and rebooting your computer removes the InnoDB: error. InnoDB: If the corrupt page is an index page InnoDB: you can also try to fix the corruption InnoDB: by dumping, dropping, and reimporting InnoDB: the corrupt table. You can use CHECK InnoDB: TABLE to scan your table for corruption. InnoDB: See also InnoDB: http://dev.mysql.com/doc/refman/5.0/en/forcing-recovery.html InnoDB: about forcing recovery. InnoDB: Ending processing because of a corrupt database page. 110716 10:19:05 mysqld ended
我真的需要這些文件才能工作,因此非常感謝任何建議。
哇,你真的在你的數據庫上做了一個數字。您可以通過複製 MySQL 數據文件來恢復,但聽起來您使用了太多的槌。正確的做法:
- 確保 MySQL未在您嘗試恢復的機器上**執行。**四重檢查
ps
以確保沒有任何類似 MySQL 的性質潛伏。如果必須,啟動到單使用者模式。如果 MySQL 正在執行,您將處理各種事情。- 複製
/var/lib/mysql
(或您的 MySQL 數據所在的任何位置)的內容以及您的my.cnf
伺服器正在使用的內容。在執行 InnoDB 時確保配置相同很重要,因為(如您所述)否則 InnoDB 將無法工作。(關鍵參數是您的 InnoDB 日誌大小/計數/等,以及每個表的文件——如果它們不同,那麼您真的無處可去)。當您啟動時,特別是如果您正在恢復因暴力而過早死亡的機器,預計伺服器需要一段時間才能啟動並執行,因為它需要進行各種內部一致性檢查(相當於)
fsck
在它準備好服務之前。