Like us on Facebook!

Monday, 8 April 2013

mysql Table is marked as crashed and should be repaired



Here is fix to little MySQL problem ...

The problem was because of a corrupt mysql table and it started on the 13th. 

[root@server01ee report]# grep "is marked as crashed and should be repaired" /var/log/mysqld.log

130202  3:20:35 [ERROR] /usr/libexec/mysqld: Table './report/lastReports' is marked as crashed and should be repaired

130202  3:20:35 [ERROR] Slave SQL: Error 'Table './report/lastReports' is marked as crashed and should be repaired' on query. Default database: 'report'. Query: 'DELETE FROM `lastReports` WHERE `timest` AND `region` = 'EQ' ORDER BY `timest` ASC LIMIT 1', Error_code: 145

130202  3:20:35 [Warning] Slave: Table './report/lastReports' is marked as crashed and should be repaired Error_code: 145

FYI,

shell > cd /var/lib/mysql/report/

shell > myisamchk lastReports.MYI

Checking MyISAM file: lastReports.MYI

Data records:      47   Deleted blocks:     372

myisamchk: warning: Table is marked as crashed

myisamchk: warning: 1 client is using or hasn't closed the table properly

- check file-size

- check record delete-chain

myisamchk: error: Record at pos: 309416 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 46 keys of 47

- check record links

myisamchk: error: Keypointers and record positions doesn't match

myisamchk: warning: Found 356432 deleted space.   Should be 362636

myisamchk: warning: Found        369 deleted blocks       Should be: 372

myisamchk: warning: Found        613 key parts. Should be: 612

MyISAM-table 'lastReports.MYI' is corrupted

Fix it using switch "-r" or "-o"

  -r, --recover       Can fix almost anything except unique keys that aren't

                      unique.

  -o, --safe-recover  Uses old recovery method; Slower than '-r' but can

                      handle a couple of cases where '-r' reports that it

                      can't fix the data file.

shell > myisamchk -r lastReports.MYI

- recovering (with sort) MyISAM-table 'lastReports.MYI'

Data records: 47

- Fixing index 1

No comments:

Post a Comment

Have your say!