网上搜了半天zabbix调优,最后结果都是一样的复制粘贴,主要都是1.8的,在这个2.0的时代,很让人难受。
我将zabbix的调优分为3部分:监控项、服务端配置、数据库
监控项:一定要自定义监控项,尽量减少没用的以及设置合理的监控周期,这个不再多说。
服务器端配置:就像其他帖子说的,优化进程数,角色分离等等,这个现在也不多说,以后碰着了再说。
数据库:我只用过mysql,所以这我就说mysql。
数据库:我要说的就是mysql的分区表,多了不说,直接上操作:
在2.0中,history、history_str、history_uint、trends、trends_uint、events这几张表大家应该比较熟悉,大量的历史数据都存在这几张表中,我们现在就对这几张表做分区:
1、分别create
以history为例:
CREATE TABLE `history` (`itemid` bigint(20) unsigned NOT NULL,`clock` int(11) NOT NULL DEFAULT '0',`value` double(16,4) NOT NULL DEFAULT '0.0000',`ns` int(11) NOT NULL DEFAULT '0',KEY `history_1` (`itemid`,`clock`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 partition by range (clock) (partition p201307 values less than (unix_timestamp("2013-07-01 00:00:00")),partition p201308 values less than (unix_timestamp("2013-08-01 00:00:00")));
1.1 alter已有的表
alter table history_uint partition by RANGE (clock) (partition p201306 values less than (unix_timestamp("2013-07-01")),partition p201307 values less than (unix_timestamp("2013-08-01")),partition p201308 values less than (unix_timestamp("2013-09-01")));
2、发现分区已经超时了,需要添加
以history为例:
alter table history add partition (partition p201309 values less than (unix_timestamp("2013-09-01 00:00:00")));
这么做之后,你会发现当你查看近一个月的数据的时候,数据出来的比较快,同时有可能之前的图像断点问题也解决了。当让,如果你愿意的话,你可以停掉housekeeper,然后写脚本定期的去删除分区,同样可以做到删除垃圾数据的效果。
今天就先写到这。