cacti 错误 ERROR: SQL Assoc Failed!, Error:\'145\'

错误描述:打开cacti监控,发现已经运行的转码机不产生流量,即cacti监控所显示已经运行的转码机为宕机,查看cacti日志发现error,查资料解决此问题、

cacit监控无数据了,查看日志:

2014年05月03日 09:05:51 AM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'145', SQL:"INSERT INTO `cacti`.`syslog_hosts` (host) (SELECT DISTINCT host FROM `cacti`.`syslog_incoming`) ON DUPLICATE KEY UPDATE host=VALUES(host), last_updated=NOW()'
2014年05月03日 09:05:51 AM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'145', SQL:"DELETE FROM `cacti`.`syslog_incoming` WHERE status=90'
2014年05月03日 09:05:51 AM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'145', SQL:"INSERT INTO `cacti`.`syslog` (logtime, priority_id, facility_id, host_id, message) SELECT TIMESTAMP(`date`, `time`), priority_id, facility_id, host_id, message FROM (SELECT date, time, priority_id, facility_id, host_id, message FROM syslog_incoming AS si INNER JOIN syslog_facilities AS sf ON sf.facility=si.facility INNER JOIN syslog_priorities AS sp ON sp.priority=si.priority INNER JOIN syslog_hosts AS sh ON sh.host=si.host WHERE status=90) AS merge'

查mysql日志:

140504 12:20:45 [ERROR] /usr/libexec/mysqld: Table './cacti/syslog_incoming' is marked as crashed and should be repaired
140504 12:20:45 [ERROR] /usr/libexec/mysqld: Table './cacti/syslog_incoming' is marked as crashed and should be repaired
140504 12:22:00 [ERROR] /usr/libexec/mysqld: Table './cacti/syslog_incoming' is marked as crashed and should be repaired
140504 12:22:00 [ERROR] /usr/libexec/mysqld: Table './cacti/syslog_incoming' is marked as crashed and should be repaired


#连接损坏表所在的数据库:

mysql> use cacti;
Database changed
# REPAIR TABLE 修复数据表
mysql> REPAIR TABLE poller_item;
+――――――-+――�C+―――-+―――-+
| Table             | Op     | Msg_type | Msg_text |
+――――――-+――�C+―――-+―――-+
| cacti. poller_item | repair | status   | OK
|
+――――――-+――�C+―――-+―――-+
1 row in set ( 0. 02 sec)
mysql>
修复成功。
如果修复失败,可以尝试用USE_FRM选项,例:
mysql> REPAIR TABLE poller_item USE_FRM;
由于表数量比较多,使用脚本进行检查和修复



#!/bin/bash

#This script used by repair tables
mysql_host=localhost
mysql_user=root

database=cacti
tables=$(mysql -h$mysql_host -u$mysql_user $database -A -Bse "show tables")
for arg in $tables
do
check_status=$(mysql -h$mysql_host -u$mysql_user $database -A -Bse "check table $arg" | awk '{ print $4 }')
if [ "$check_status" = "OK" ]
then
echo "$arg is ok"
else
echo $(mysql -h$mysql_host -u$mysql_user $database -A -Bse "repair table $arg")
fi
echo $(mysql -h$mysql_host -u$mysql_user $database -A -Bse "optimize table $arg")
done


你可能感兴趣的:(error,status,failed)