- 1、本文档共15页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Zabbix优化之分区操作教程
登录MySQL数据库
登录MySQL,进入zabbix数据库,命令参考如下:
$ mysql -uroot -p -h127.0.0.1
mysql use zabbix
查看是否支持分区
对于5.6以及以后版本的MySQL数据库,采用show plugins来查看是否支持分区,如果partition处于 active状态,则支持分区,否则,必须加载该插件。
命令参考如下:
mysql show plugins;
分区操作
分区操作方式
对zabbix数据库表进行分区操作,一般可以采用两种方式:
使用MySQL存储过程
使用SQL脚本
因为存储过程在调试时,一旦遇到任何问题,调试可能会更复杂,所以,在这里采用SQL脚本的方式来实现。
分区类型与策略
根据数据库表格中的数据特征,对下述数据库表,按日或者按月两种类型,分别进行分区:
按日分区
history
history_log
history_str
history_text
history_uint
按月分区
acknowledges
alerts
auditlog
events
service_alarms
trends
trends_uint
主键/唯一索引管理
因MySQL内部的限制???在正式分区前,一些主键、唯一索引需要删除,用非唯一索引来代替。
Zabbix 2.2及以后的版本中,如zabbix 3.0.2,下述唯一索引需删除,参考命令如下:
mysql alter table history_log drop primary key, add index history_log_0 (id);
mysql alter table history_log drop key history_log_2;
mysql alter table history_text drop primary key, add index history_text_0(id);
mysql alter table history_text drop key history_text_2;
mysql alter table acknowledges drop primary key, add key acknowledges_0 (acknowledgeid);
mysql alter table alerts drop primary key, add key alerts_0 (alertid);
mysql alter table auditlog drop primary key, add key auditlog_0 (auditid);
mysql alter table events drop primary key, add key events_0 (eventid);
mysql alter table service_alarms drop primary key, add key service_alarms_0 (servicealarmid);
外键管理
Zabbix 2.0及以后的版本中,如zabbix 3.0.2,下述外键需删除,参考命令如下:
mysql alter table acknowledges drop foreign key c_acknowledges_1, drop foreign key c_acknowledges_2;
mysql alter table alerts drop foreign key c_alerts_1, drop foreign key c_alerts_2, drop foreign key c_alerts_3, drop foreign key c_alerts_4;
mysql alter table auditlog drop foreign key c_auditlog_1;
mysql alter table service_alarms drop foreign key c_service_alarms_1;
mysql alter table auditlog_details drop foreign key c_auditlog_details_1;
确定最小时钟
确定分区时,需查询该数据库表的分区字段的最小时钟,以history_uint表示例,如下:
mysql select from_unixtime(min(clock)) from history_uint;
添加分区
根据上一部操作中的最小时间,对要进行分区划分的表进行分区划分,以history_uint表示例,如下:
mysql alter table history_uint partition by range
您可能关注的文档
最近下载
- 《GB50242-2016建筑给排水及采暖工程施工质量验收规范(条文说明)》.pdf
- 《严格规范涉企行政检查》专题讲座.pptx VIP
- 最高法院第一巡回法庭关于行政审判法律适用若干问题的会议纪要.pdf VIP
- 七年级的道德与法制下册知识点.doc VIP
- 2025年高考语文课内文言文知识梳理(统编版)《子路、曾皙、冉有、公西华侍坐》(原卷版).pdf VIP
- 苏教版初中数学八年级下册《反比例函数》单元检测试卷及参考答案.pdf VIP
- 厂区零星工程施工方案(3篇).docx VIP
- 应急管理部关于严格规范安全生产执法行为的通知专题宣贯学习.pptx VIP
- 2025年全国保密教育线上培训考试题(含答案).docx VIP
- 七年级上册《道德与法制》知识点归纳.docx VIP
文档评论(0)