稼働中のPCやら衝動買いしたPCやら実験やら破壊やら構築やら。
情報としての価値はほぼなし。
なんていうか完全に自己満足。
要するについてくる人が居ないのでこっちに書くだけの話っていうかチラシの裏。
※あと、お仕事募集中
コンタクトはk.haramai[atmark]gmail.com まで。

2012/03/18

Crashed Zabbix Database

しばらく放置というか、起動状態でほうっておいたZabbixだったが、久しぶりにスクリーンを覗いてみるとデータが未取得となっていた。

具体的にはこんなメッセージが/var/log/zabbix/zabbix_server.logに上がっていた。

3223:20120318:062815.752 [Z3005] Query failed: [145] Table './zabbix/history' is marked as crashed and should be repaired [select min(clock) from history where itemid=19976]

おやー?と思って、mysqlから接続してDBを見る。


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| clipbucket         |
| mysql              |
| test               |
| zabbix             |
+--------------------+
5 rows in set (0.00 sec)


とりあえず、接続は出来る。

次にZabbixのDBへ接続して該当テーブルをチェック。


mysql> use zabbix;
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> check table history extended;
+----------------+-------+----------+----------------------------------------------------------+
| Table          | Op    | Msg_type | Msg_text                                                 |
+----------------+-------+----------+----------------------------------------------------------+
| zabbix.history | check | warning  | Table is marked as crashed                               |
| zabbix.history | check | warning  | 2 clients are using or haven't closed the table properly |
| zabbix.history | check | error    | Key in wrong position at page 49271808                   |
| zabbix.history | check | error    | Corrupt                                                  |
+----------------+-------+----------+----------------------------------------------------------+
4 rows in set (15 min 31.31 sec)

あー、そうですかそうですか。
ぶっ壊れてるんですね。

repairをかける前にMySQLを止めてバックアップを取得。

#service mysqld stop 
#cp -rp /var/lib/mysql /opt/mysqlback

んでもって起動してrepair処理を実行。

#service mysqld start

mysql> repair table zabbix.history;
+----------------+--------+----------+----------+
| Table          | Op     | Msg_type | Msg_text |
+----------------+--------+----------+----------+
| zabbix.history | repair | status   | OK       |
+----------------+--------+----------+----------+
1 row in set (4 min 51.48 sec)

終了、戻ってよかったよかったというお話。