zabbix mysql 8g优化_Zabbix优化之必杀技-表分区_MySQL

时间2014-05-06

作者itnihao

邮箱itnihao@qq.com

博客http://www.itnihao.com

如需引用,请注明以上信息,谢谢合作

前言,使用zabbix最大的瓶颈在于数据库,维护好zabbix的数据存储,告警,即能够很好的应用zabbix去构建监控系统。本文所讲的正是数据存储部分。本文所针对的用户,需要对zabbix有一定概念,对MySQL熟悉,掌握存储过程的书写,对zabbix数据库字段熟悉

本部分内容来自本人的新书,作为对新书分表章节的部分补充,书名叫《zabbix监控系统》,将于2014-06与读者面市。书的章节目录已经放在github上面

https://github.com/itnihao/zabbix-book/blob/master/README.md

Zabbix中历史数据的

zabbix对数据将数据存于数据库,其主要将历史数据存于history和trends的2个表中,如下

1)历史数据的表

1405KLO29E0-64T5.jpg

2)警告日志数据的表

1405KLOL560-M5M.jpg

History表结构mysql> show create table history/G;*************************** 1. row *************************** Table: historyCreate Table: 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=utf8mysql> show create table history_str/G; Table: history_strCreate Table: CREATE TABLE `history_str` (`itemid` bigint(20) unsigned NOT NULL,`clock` int(11) NOT NULL DEFAULT '0',`value` varchar(255) NOT NULL DEFAULT '',`ns` int(11) NOT NULL DEFAULT '0',KEY `history_str_1` (`itemid`,`clock`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mysql> show create table history_str_sync /G;*************************** 1. row *************************** Table: history_str_syncCreate Table: CREATE TABLE `history_str_sync` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,`nodeid` int(11) NOT NULL,`itemid` bigint(20) unsigned NOT NULL,`clock` int(11) NOT NULL DEFAULT '0',`value` varchar(255) NOT NULL DEFAULT '',`ns` int(11) NOT NULL DEFAULT '0',PRIMARY KEY (`id`),KEY `history_str_sync_1` (`nodeid`,`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mysql> show create table history_sync /G;*************************** 1. row *************************** Table: history_syncCreate Table: CREATE TABLE `history_sync` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,`nodeid` int(11) NOT NULL,`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',PRIMARY KEY (`id`),KEY `history_sync_1` (`nodeid`,`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mysql> show create table history_text /G;*************************** 1. row *************************** Table: history_textCreate Table: CREATE TABLE `history_text` (`id` bigint(20) unsigned NOT NULL,`itemid` bigint(20) unsigned NOT NULL,`clock` int(11) NOT NULL DEFAULT '0',`value` text NOT NULL,`ns` int(11) NOT NULL DEFAULT '0',PRIMARY KEY (`id`),UNIQUE KEY `history_text_2` (`itemid`,`id`),KEY `history_text_1` (`itemid`,`clock`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mysql> show create table history_log/G;*************************** 1. row *************************** Table: history_logCreate Table: CREATE TABLE `history_log` (`id` bigint(20) unsigned NOT NULL,`itemid` bigint(20) unsigned NOT NULL,`clock` int(11) NOT NULL DEFAULT '0',`timestamp` int(11) NOT NULL DEFAULT '0',`source` varchar(64) NOT NULL DEFAULT '',`severity` int(11) NOT NULL DEFAULT '0',`value` text NOT NULL,`logeventid` int(11) NOT NULL DEFAULT '0',`ns` int(11) NOT NULL DEFAULT '0',PRIMARY KEY (`id`),UNIQUE KEY `history_log_2` (`itemid`,`id`),KEY `history_log_1` (`itemid`,`clock`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mysql> show create table history_uint /G;*************************** 1. row *************************** Table: history_uintCreate Table: CREATE TABLE `history_uint` (`itemid` bigint(20) unsigned NOT NULL,`clock` int(11) NOT NULL DEFAULT '0',`value` bigint(20) unsigned NOT NULL DEFAULT '0',`ns` int(11) NOT NULL DEFAULT '0',KEY `history_uint_1` (`itemid`,`clock`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mysql> show create table history_uint_sync/G;*************************** 1. row *************************** Table: history_uint_syncCreate Table: CREATE TABLE `history_uint_sync` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,`nodeid` int(11) NOT NULL,`itemid` bigint(20) unsigned NOT NULL,`clock` int(11) NOT NULL DEFAULT '0',`value` bigint(20) unsigned NOT NULL DEFAULT '0',`ns` int(11) NOT NULL DEFAULT '0',PRIMARY KEY (&#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值