2013年5月28日 星期二

修復Asterisk cdr table

今天突然發現Trixbox無法顯示CDR Report, 用console進入mysql, 下select指令得到下列錯誤訊息:

mysql> use asteriskcdrdb;
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 cdr order by calldate;
ERROR 1194 (HY000): Table 'cdr' is marked as crashed and should be repaired

原來是cdr這個table壞掉了, 還好GOOGLE了一下,有解決方法,還蠻簡單的

檢查確定table真的壞了:
 mysql> check table cdr;
+-------------------+-------+----------+----------------------------------------------------------+
| Table             | Op    | Msg_type | Msg_text                                                 |
+-------------------+-------+----------+----------------------------------------------------------+
| asteriskcdrdb.cdr | check | warning  | 9 clients are using or haven't closed the table properly |
| asteriskcdrdb.cdr | check | error    | Found wrong record at 1660304                            |
| asteriskcdrdb.cdr | check | error    | Corrupt                                                  |
+-------------------+-------+----------+----------------------------------------------------------+
3 rows in set (0.04 sec)

只要下repair table cdr 一行指令就搞定
mysql> repair table cdr;
+-------------------+--------+----------+----------------------------------------------+
| Table             | Op     | Msg_type | Msg_text                                     |
+-------------------+--------+----------+----------------------------------------------+
| asteriskcdrdb.cdr | repair | info     | Key 1 - Found wrong stored record at 1660304 |
| asteriskcdrdb.cdr | repair | warning  | Number of rows changed from 13922 to 13065   |
| asteriskcdrdb.cdr | repair | status   | OK                                           |
+-------------------+--------+----------+----------------------------------------------+
3 rows in set (0.13 sec)

沒有留言:

張貼留言