Sunday, October 11, 2015

MySQL table is marked as crashed and should be repaired on Nagios


MySQL table is marked as crashed and should be repaired on Nagios  or Any Other Applications


Cause:


Often after running a similar unexpected events. Frequently Linux file system / Windows drive out of disk space, some of the database tables may have become corrupt. This often occurs after you experience out of disk space problems on the disk partition where your database resides.

Symptoms of corrupted tables include queries that abort unexpectedly and observable errors such as these:
  • tbl_name.frm is locked against change.
  • Can't find file tbl_name.MYI.
  • Unexpected end of file.
  • Record file is crashed.
  • Got error nnn from table handler.

Error Code:


151010 13:00:59 [ERROR] /usr/libexec/mysqld: Table './nagios/nagios_timedevents' is marked as crashed and should be repaired
151010 13:00:59 [ERROR] /usr/libexec/mysqld: Table './nagios/nagios_timedeventqueue' is marked as crashed and should be repaired
151010 13:04:00 [ERROR] /usr/libexec/mysqld: Table './nagios/nagios_systemcommands' is marked as crashed and should be repaired
151010 13:04:00 [ERROR] /usr/libexec/mysqld: Table './nagios/nagios_hostchecks' is marked as crashed and should be repaired
.......................................Etc.

Resolution:

Perform below steps on MySQL DB.

mysql> select * from nagios_servicechecks;

ERROR 1046 (3D000): No database selected

mysql> SELECT database();
+------------+
| database() |
+------------+
| NULL       |
+------------+
1 row in set (0.00 sec)

mysql> USE nagios

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> select * from nagios_servicechecks;

ERROR 145 (HY000): Table './nagios/nagios_servicechecks' is marked as crashed and should be repaired.

mysql> REPAIR TABLE nagios_servicechecks;

+-----------------------------+--------+----------+-------------------------------------------------------------------------------+
| Table                       | Op     | Msg_type | Msg_text                                                                      |
+-----------------------------+--------+----------
| nagios.nagios_servicechecks | repair | info     | Wrong block with wrong total length starting at 4322280                       |
| nagios.nagios_servicechecks | repair | info     | Wrong block with wrong total length starting at 4322928        
.......Etc


mysql> REPAIR TABLE nagios_servicestatus; 
mysql> REPAIR TABLE nagios_hostchecks;
mysql> REPAIR TABLE nagios_systemcommands;
mysql> REPAIR TABLE nagios_timedeventqueue;

mysql> REPAIR TABLE nagios_timedevents;



No comments:

Post a Comment

Gitlab Automation Project Showcase

My GitLab Projects Showcase 🚀 Welcome to my portfolio of GitLab projects. Each repository reflects my journey as an engineer, focusing...