原因分析

为了防止数据库持续增大,Zabbix有自动删除历史数据的机制,即housekeeper,而在频繁清理历史数据的时候,MySQL数据库可能出现性能降低的情况,此时就会告警。

一般来说,Zabbix都会监控Zabbix Server本身。如下所示,我们可以分析“Zabbix server: Utilization of housekeeper internal processes, in %”图形,通过分析,我们可以看到Zabbix housekeeper processes在10点32分的时候, housekeeper进程突然开始繁忙。

拉长时间范围的截图如下所示:

如需进一步分析,那么就必须查看MySQL的慢查询日志:

mysql> show variables like '%slow_query%';

+---------------------+-------------------------------------+

| Variable_name       | Value                               |

+---------------------+-------------------------------------+

| slow_query_log      | ON                                  |

| slow_query_log_file | /mysql_data/mysql/xxxx-slow.log |

+---------------------+-------------------------------------+

2 rows in set (0.01 sec)

#注意,如果没有设置过的话,这里默认是UTC时间。所以跟东八区时间有所区别。

# Time: 2020-08-26T02:34:56.354162Z

# User@Host: zabbix[zabbix] @ localhost []  Id: 345463

# Query_time: 13.832335  Lock_time: 0.000088 Rows_sent: 0  Rows_examined: 5000

SET timestamp=1598409282;

delete from history where itemid=37078 limit 5000;

# Time: 2020-08-26T02:35:00.377783Z

# User@Host: zabbix[zabbix] @ localhost []  Id: 345463

# Query_time: 4.023518  Lock_time: 0.000126 Rows_sent: 0  Rows_examined: 5000

SET timestamp=1598409296;

delete from history where itemid=37079 limit 5000;

# Time: 2020-08-26T02:35:36.848120Z

# User@Host: zabbix[zabbix] @ localhost []  Id: 345463

# Query_time: 21.513432  Lock_time: 0.000094 Rows_sent: 0  Rows_examined: 5000

SET timestamp=1598409315;

delete from history where itemid=37099 limit 5000;

# Time: 2020-08-26T02:35:46.705206Z

# User@Host: zabbix[zabbix] @ localhost []  Id: 345463

# Query_time: 9.856468  Lock_time: 0.000124 Rows_sent: 0  Rows_examined: 5000

SET timestamp=1598409336;

delete from history where itemid=37100 limit 5000;

# Time: 2020-08-26T02:36:43.856421Z

# User@Host: zabbix[zabbix] @ localhost []  Id: 345463

# Query_time: 38.186585  Lock_time: 0.000039 Rows_sent: 0  Rows_examined: 5000

SET timestamp=1598409365;

delete from history where itemid=38789 limit 5000;

# Time: 2020-08-26T02:36:59.432174Z

# User@Host: zabbix[zabbix] @ localhost [127.0.0.1]  Id: 345563

# Query_time: 8.542213  Lock_time: 0.000084 Rows_sent: 20  Rows_examined: 7298

SET timestamp=1598409410;

SELECT DISTINCT e.eventid,e.clock,e.ns,e.objectid,e.acknowledged,er1.r_eventid FROM events e LEFT JOIN event_recovery er1 ON er1.eventid=e.eventid WHERE e.sou

rce='0' AND e.object='0' AND e.objectid=26811 AND e.eventid<='3437835' AND e.value=1 ORDER BY e.eventid DESC LIMIT 20;

# Time: 2020-08-26T02:37:02.317422Z

# User@Host: zabbix[zabbix] @ localhost []  Id: 345463

# Query_time: 18.460853  Lock_time: 0.000101 Rows_sent: 0  Rows_examined: 5000

SET timestamp=1598409403;

delete from history where itemid=38790 limit 5000;

另外,Zabbix Server也会将慢查询SQL写入zabbix_server.log中,如下所示。

# grep "slow query" zabbix_server.log

通过分析,我们可以发现MySQL在删除history和histry_unit数据。经过分析,这里突然出现 housekeeper进程繁忙,是因为我删除了模板Zabbix template for Microsoft SQL Server,并勾选了Clear,所以导致Zabbix Server需要删除大量的数据。当然这个只是一个诱因,本身history变得非常大才是一个重要的原因。你可以通过下面脚本,查看一下这些表的Size大小信息。

SELECT TABLE_SCHEMA

    ,  TABLE_NAME

    , (DATA_LENGTH/1024/1024)     AS DATA_SIZE_MB 

    , (INDEX_LENGTH/1024/1024)  AS INDEX_SIZE_MB

    , ((DATA_LENGTH+INDEX_LENGTH)/1024/1024) AS TABLE_SIZE_MB

    , TABLE_ROWS 

FROM INFORMATION_SCHEMA.TABLES 

WHERE table_schema = 'zabbix'

ORDER BY TABLE_SIZE_MB ASC;

解决方案

一般短时间出现这样的告警可以忽略,如果一直出现这个告警的话,我们就应该调整参数HousekeepingFrequency和MaxHousekeeperDelete。

Zabbix 5.x下面,默认情况下HousekeepingFrequency值为1,表示一小时执行一次。 MaxHousekeeperDelete表示一次删除5000条记录。如下所示

# grep -C 1 HousekeepingFrequency /etc/zabbix/zabbix_server.conf

 

### Option: HousekeepingFrequency

#       How often Zabbix will perform housekeeping procedure (in hours).

#       Housekeeping is removing outdated information from the database.

#       To prevent Housekeeper from being overloaded, no more than 4 times HousekeepingFrequency

#       hours of outdated information are deleted in one housekeeping cycle, for each item.

#       To lower load on server startup housekeeping is postponed for 30 minutes after server start.

#       With HousekeepingFrequency=0 the housekeeper can be only executed using the runtime control option.

#       In this case the period of outdated information deleted in one housekeeping cycle is 4 times the

--

# Default:

# HousekeepingFrequency=1

 

 

# grep -C 1 MaxHousekeeperDelete  /etc/zabbix/zabbix_server.conf

 

### Option: MaxHousekeeperDelete

#       The table "housekeeper" contains "tasks" for housekeeping procedure in the format:

#       [housekeeperid], [tablename], [field], [value].

#       No more than 'MaxHousekeeperDelete' rows (corresponding to [tablename], [field], [value])

#       will be deleted per one task in one housekeeping cycle.

--

# Default:

# MaxHousekeeperDelete=5000

HousekeepingFrequency介绍:

 

Zabbix 执行housekeeping 的频率 (单位为小时)。

housekeeping负责从数据库中删除过期的信息。

注意: 为了防止 housekeeper 负载过大 (例如, 当历史和趋势周期大大减小时), 对于每一个监控项,不会在一个housekeeping周期内删除超过4倍HousekeepingFrequency 的过期数据。 因此, 如果 HousekeepingFrequency 是 1小时, 一个周期内不会删除超过4小时的过期信息 (从最旧的数据开始) 。

备注: 为降低 server压力, housekeeping将在server启动以后,延迟30分钟执行。 因此, 如果 HousekeepingFrequency 是1小时,serverg启动30分后执行第一次 housekeeping , 然后按1小时为周期重复执行。从Zabbix 2.4.0以后有了这种延迟行为。

从Zabbix 3.0.0开始,可以设置HousekeepingFrequency为0来禁止自动housekeeping。 此时 housekeeping 只能通过 housekeeper_execute 启动, 在一个housuekeeping周期内删除的过期信息时长为从最后一次housekeeping以来到配置周期的4倍,不少于4小时且不大于4天。

MaxHousekeeperDelete介绍:

从Zabbix 1.8.2 开始支持该参数,如果MaxHousekeeperDelete设置为0,表示不限制删除的行数。当然不建议这么做。它仅适用于那些准备删除的历史数据和历史趋势数据。

一般是通过将housekeeper进程做归档的时间间隔调大,一次删除数据的量放大来解决问题。至于这个值到底多大合适,没有统一标准。要根据实际情况、测试才能给出一个合适的值。

HousekeepingFrequency=6           #间隔时间6小时

MaxHousekeeperDelete=10000        #最大删除量

在这个案例中,将MaxHousekeeperDelete调整为100000,发现delete操作反而慢了许多。如下所示:

836378:20200826:161213.441 slow query: 773.254950 sec, "delete from history where itemid=45251 limit 100000"

836378:20200826:162435.978 slow query: 742.537260 sec, "delete from history where itemid=46694 limit 100000"

836378:20200826:163329.011 slow query: 532.932137 sec, "delete from history where itemid=51313 limit 100000"

836378:20200826:163842.539 slow query: 313.528311 sec, "delete from history where itemid=52664 limit 100000"

如果我将MaxHousekeeperDelete调整为10000的话,发现delete的性能还是要快一些。所以,这个不妨多测试验证一下。

943980:20200826:233157.246 slow query: 5.393617 sec, "delete from history where itemid=37769 limit 10000"

943980:20200826:233202.914 slow query: 5.667551 sec, "delete from history where itemid=38407 limit 10000"

943980:20200826:233208.044 slow query: 5.129767 sec, "delete from history where itemid=41283 limit 10000"

943980:20200826:233217.462 slow query: 7.011403 sec, "delete from history where itemid=37770 limit 10000"

943980:20200826:233222.516 slow query: 5.053935 sec, "delete from history where itemid=38408 limit 10000"

943980:20200826:233227.286 slow query: 4.769753 sec, "delete from history where itemid=41284 limit 10000"

另外,还有一些方法,例如减少历史数据的保留时间、对history等大表进行分区,也可以避免或减少这个告警出现的概率。根据个人的经验,如果像history表变得非常大以后,即使调整上面参数,其实效果并不明显。需要通过分区或手工清理历史数据来解决。这样效果才显著。

Zabbix housekeeper processes more than 75% busy的更多相关文章

  1. Zabbix poller processes more than 75% busy

    Centos7.5  在设置网络监控的时候zabbix提示Zabbix poller processes more than 75% busy 问题 原因 默认只开启一个Discoverers进程,就 ...

  2. zabbix 邮件报警事件:Zabbix discoverer processes more than 75% busy

    Problem has been resolved at :: on Problem name: Zabbix discoverer processes more than % busy Host: ...

  3. zabbix告警“Zabbix poller processes more than 75% busy”

    告警原因: 1.某个进程卡住了, 2.僵尸进程出错,太多,导致慢了 3.网络延迟(可忽略) 4.zabbix消耗的内存多了 告警危害: 普通告警,暂无危害(但是最好处理) 处理方法: 一:简单,粗暴( ...

  4. Zabbix discoverer processes more than 75% busy

    [root@86 ~]# grep -n "StartDiscoverers" /usr/local/zabbix/etc/zabbix_server.conf 176:### O ...

  5. Zabbix unreachable poller processes more than 75% busy

    “Zabbix poller processes more than 75% busy”警报问题解决 虽然Zabbix的监控警报各种有,碰到最多的几个莫过于内存耗尽,网络不通,IO太慢还有这个“Zab ...

  6. Zabbix报错:"Zabbix http poller processes more than 75% busy"的解决

    一.钉钉收到告警 主机名称:Zabbix服务端-172.28.18.75 IP地址 :127.0.0.1 告警时间:2019.10.22 13:34:39 告警信息:Zabbix http polle ...

  7. Zabbix icmp pinger processes more than 75% busy

    Zabbix icmp pinger processes more than 75% busy   Zabbix server报"Zabbix icmp pinger processes m ...

  8. 解决CentOS“Zabbix discoverer processes 75% busy”的问题

    解决CentOS“Zabbix discoverer processes 75% busy”的问题 运维  立杰  4年前 (2014-08-11)  1104℃  0评论 在使用Zabbix过程中, ...

  9. Zabbix服务网页报错汇总

    第1章 Zabbix简介及组成 1.1 zabbix简介 zabbix是一个基于web界面,提供分布式系统监视以及网络监视功能的企业级的开源解决方案.它可以监视各种网络参数,保证服务器自动的安全运营, ...

随机推荐

  1. SEO(Search Engine Optimization)优化

    SEO(Search Engine Optimization)汉议为搜索引擎优化,是一种利用搜索引擎的规则提高网站在有关搜索引擎内自然排名的方式. SEO的目的是对网站进行深度的优化,从而帮助网站获取 ...

  2. 【av68676164(p51-p53)】虚拟内存管理(2)

    虚拟内存管理(2) 7.3.4 缺页终端 分级存储体系 cache+内存+辅存 页表扩充-带中断位的页表 页号 页框号 中断位I 辅存地址 访问位 修改位 1 1 0 0 0 1 中断位I-标志该页是 ...

  3. 【Python笔记】2020年7月30日练习【python用input函数输入一个列表】

    练习课题链接:廖雪峰-Python教程-高级特性-迭代 学习记录: 1.Python当中类似于 三目运算符 的应用 2.Python用input函数输入一个列表 代码实例:对用户输入的一组数字转化成l ...

  4. C#LeetCode刷题-栈

    栈篇 # 题名 刷题 通过率 难度 20 有效的括号 C#LeetCode刷题之#20-有效的括号(Valid Parentheses) 33.0% 简单 42 接雨水   35.6% 困难 71 简 ...

  5. Remix+Geth 实现智能合约部署和调用详解

    Remix编写智能合约 编写代码 在线调试 实现部署 调用接口 Geth实现私有链部署合约和调用接口 部署合约 调用合约 获得合约实例 通过实例调用合约接口 Remix编写智能合约 编写代码 Remi ...

  6. iOS Abort问题系统性解决方案

    一.背景 崩溃(Crash),即闪退,多指移动设备(如iOS.Android设备)在打开/使用应用程序的过程中,突然出现意外退出/中断的情况.如果App线上版本频繁发生崩溃,会极大地影响用户体验,甚至 ...

  7. ThinkPHP 6.0 基础教程 - 安装

    ThinkPHP6.0 的环境: PHP >= 7.1.0 我本地环境: Win10 PhpStudy 安装 PhpStudy 如果你已经安装 PhpStudy 或其他环境,请忽略这里 安装方法 ...

  8. 【趣味设计模式系列】之【代理模式2--JDK动态代理源码解析】

    1. 图解 上图主要描述了JDK动态代理的执行过程,下面做详细分析. 2. Proxy源码分析 上一篇,在使用JDK动态代理的时候,借助于Proxy类,使用newProxyInstance静态方法,创 ...

  9. 【期外】(二)还是N皇后动画演示

    题目:n皇后题目 题解:n皇后题解 演示:

  10. python利用爬虫获取百度翻译,爱词霸翻译结果,制作翻译小工具

    先看效果展示(仅作学习使用,非商业) 效果图是采用的 爱词霸 翻译,百度翻译 也实现了,只不过被注释了. 学计算机很多时候碰到生词,每次打开手机/浏览器翻译总觉得很麻烦,就想着自己写一个软件,自己去实 ...