Zabbix性能优化

前言

如果不做表分区和删除历史数据规则设置的话,随着时间的推移zabbix的查询性能会变得很低

查看zabbix的性能

通过zabbix的NVPS(每秒处理数值数)来衡量其性能,在zabbix的dashboard上有一个粗略的估值

数据库优化

一、设置独立表空间(innodb_file_per_table=1)  # 5.6版本以上自动开启 以上版本跳过这一段

1、删除history数据

truncate history
truncate history_uint

2、备份数据

mysqldump -uroot -p123456 zabbix > zabbix.sql

3、开启独立表空间

innodb_file_per_table=1

4、还原数据

mysql -uroot -p123456 zabbix < zabbix.sql

5、重启数据库  # 先删除ib_logfile0,ib_logfile1

/etc/init.d/mysqld restart

6、回收表空间(对应操作1)

optimize history
optimize history_uint

二、表分区

需要分区的表  # history* 有着一样的字段,存储着不同类型item的历史数据。trend* 有着一样的字段,存储着不同类型item的历史趋势数据

history
history_log
history_str
history_text
history_uint
trends
trends_uint

 表分区存储过程详细见 https://www.zabbix.org/wiki/Docs/howto/mysql_partition

加入计划任务

1 0 * * * /storage/server/mysql/bin/mysql -uroot -p123456 zabbix -e "CALL partition_maintenance_all('zabbix');"

参考:http://xianglinhu.blog.51cto.com/5787032/1700981

原文地址:https://www.cnblogs.com/metasequoia/p/5805845.html