Jan 9 08:55:36 web /etc/mysql/debian-start[656]: drupal.sessions
Jan 9 08:55:36 web /etc/mysql/debian-start[656]: warning : Table is marked as crashed
Jan 9 08:55:36 web /etc/mysql/debian-start[656]: warning : 1 client is using or hasn't closed the table properly
Can't open file: 'sessions.MYI'. (errno: 145)
目前原因不明,暫時的解決方式:
啟動mysql後,用REPAIR TABLE語法來修復資料表
REPAIR TABLE sessions
re: drupal sessions 資料表毀損
sessions 屬於MYISAM 表的一種,因此都可以適用Mysql 針對MYISAM 所設計的修復方式myisamchk,尤其是當crashed tables 無法被phpmyadmin 開啟或修復時,或是擔心以舊資料表備份修復資料庫,會造成的後續維護上的麻煩。
步驟1: 自遠端登錄後,將會用到資料庫服務關閉(apache、mysql、…)。
步驟2: 完成確認mysql 程序都已經結束後,可以先用myisamchk 可以先確認損壞情況
# myisamchk -a sessions
Checking MyISAM file: sessions
Data records: 16309 Deleted blocks: 11923
myisamchk: warning: Table is marked as crashed
myisamchk: warning: 2 clients are using or haven't closed the table properly
- check file-size
- check record delete-chain
myisamchk: error: Record at pos: 2399200 is not remove-marked
myisamchk: error: record delete-link-chain corrupted
- check key delete-chain
- check index reference
- check data record references index: 1
myisamchk: error: Found 16305 keys of 16309
- check record links
myisamchk: error: Unexpected byte: 3 at link: 2399200
MyISAM-table 'sessions' is corrupted
Fix it using switch "-r" or "-o"
接下來就按照指示下 myisamchk -r sessions 就可以修復囉!
# myisamchk -r sessions
- recovering (with sort) MyISAM-table 'sessions'
Data records: 16309
- Fixing index 1
Found block that points outside data file at 881208
- Fixing index 2
- Fixing index 3
Data records: 16303
照技術手冊描述,絕大部份的 MYISAM table 都可以用myisamchk 來修復。
這樣就可以重新開啟 mysql、apache了。
引用文獻: mysql 管理手札(MySQL Press 著) 上奇出版