zabbix清空历史记录
- 博客分类:
- zabbix
阅读更多
由于zabbix每天收集大量记录,清理过期的数据以提高查询性能。
mysql -uroot -p 输入mysql密码
use zabbix;
-----------------------------------------------------------------------
truncate table history;
optimize table history;
-----------------------------------------------------------------------
truncate table history_str;
optimize table history_str;
-----------------------------------------------------------------------
truncate table history_uint;
optimize table history_uint;
-----------------------------------------------------------------------
truncate table trends;
optimize table trends;
-----------------------------------------------------------------------
truncate table trends_uint;
optimize table trends_uint
-----------------------------------------------------------------------
truncate table events;
ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint (`zabbix`.`acknowledges`, CONSTRAINT `c_acknowledges_2` FOREIGN KEY (`eventid`) REFERENCES `zabbix`.`events` (`eventid`))
Mysql中如果表和表之间建立的外键约束,则无法删除表及修改表结构
-----------------------------------------------------------------------
解决方法:
mysql> SET foreign_key_checks=0;
truncate table events; optimize table events;
mysql> SET foreign_key_checks=1;
注意:此语句会清空zabbix所有历史监控数据,请慎用!
(adsbygoogle = window.adsbygoogle || []).push({});