您的位置:首页 > 数据库

zabbix数据库历史数据清除

2016-07-12 00:00 567 查看
摘要: 线上zabbix用了有点时间了,再加上最近公司业务问题,想把生产上的zabbix数据库瘦身一下.

线上zabbix用了有点时间了,再加上最近公司业务问题,想把生产上的zabbix数据库瘦身一下.

别说一找,还真有.

先暂停zabbix.当然是service zabbix_server stop

然后最好也把http停掉 service httpd stop

连上数据库:

mysql -u root(zabbix) -p

use zabbix

核心语句:

SELECT table_name AS "Tables",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = 'zabbix'
ORDER BY (data_length + index_length) DESC;

别人写的,我在网上找了.查看各个表的数据大小.

Tables                | Size in MB |
+-----------------------+------------+
| alerts                |    2560.88 |
| history_uint          |    2004.25 |
| history               |     816.47 |
| trends_uint           |     450.66 |
| trends                |     237.50 |
| events                |     162.44 |
| history_text          |     135.25 |
| items                 |       2.09 |
| images                |       1.53 |
| history_str           |       1.33

另外就是把不历史表和报警表数据清空

truncate table history;
truncate table history_uint;
truncate table alerts;
truncate table trends_uint;
truncate table trends;
truncate table history_text;
truncate table events;

使用delete的话,也会清空数据,但是不会更改表中的记录ID.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: