Venant d'avoir un crash de ma table './bacula/File' sur un de mes serveurs de backup, je vous donne tout de suite la solution pour réparer cette table.
L'erreur indiquée est la suivante :
Table './bacula/File' is marked as crashed and should be repaired
La table ./bacula/File nécessite d'être réparée.
Nous allons commencer par faire une vérification en utilisant
myisamchk avec l'option
-c pour check :
On suppose que par défaut, vos base MySQL sont dans le dossier :
/var/lib/mysql/
$ myisamchk -c /var/lib/mysql/bacula/File.MYI
Checking MyISAM file: /var/lib/mysql/bacula/File.MYI
Data records: 6061041 Deleted blocks: 479746
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: 281313488 is not remove-marked
myisamchk: error: record delete-link-chain corrupted
- check key delete-chain
myisamchk: error: key delete-link-chain corrupted
- check record links
myisamchk: error: Record-count is not ok; is 6064225 Should be: 6061041
myisamchk: warning: Found 46149316 deleted space. Should be 46460600
myisamchk: warning: Found 476562 deleted blocks Should be: 479746
MyISAM-table '/var/lib/mysql/bacula/File.MYI' is corrupted
Fix it using switch "-r" or "-o"
Comme nous indique myisamchk, nous allons réparer la table avec l'option
-r :
$ myisamchk -r /var/lib/mysql/bacula/File.MYI
- recovering (with sort) MyISAM-table '/var/lib/mysql/bacula/File.MYI'
Data records: 6061041
- Fixing index 1
- Fixing index 2
- Fixing index 3
- Fixing index 4
- Fixing index 5
Data records: 6064225
Et là on a gagné ;-) la table est réparée