问题现象
OCP 频繁告警 monitor_exporter_unavaliable 及其恢复告警,告警事件详情如下:
- 告警概述:alarm_template_id=0:host=xx.xx.xx.xx:exporter=/metrics/ob/basic 服务器存在监控 exporter 异常
- 告警详情:主机:xx.xx.xx.xx,告警:监控 exporter http://xx.xx.xx.xx:62889/metrics/ob/basic(类型:OB_CLUSTER,采集间隔:15 秒)异常。
查看告警主机的
/home/admin/ocp_agent/log/monagent.log,一直存在如下类似错误,其中 xx.xx.xx.1 为 OCP Server 主机,且 ocp_monitor 租户配置符合要求,无明显资源压力。2025-03-14T19:03:47.81301+08:00 ERROR [1718143,80634c28cbfb8758] caller=engine/route_manager.go:210:ServeHTTP: failed to write http response from buffer fields: error=“write tcp xx.xx.xx.2:62889->xx.xx.xx.1:41226: write: broken pipe” 2025-03-14T19:04:02.29958+08:00 ERROR [1718143,dbaa0e2cc31f7fd6] caller=engine/route_manager.go:210:ServeHTTP: failed to write http response from buffer fields:, error=“write tcp xx.xx.xx.2:62889->xx.xx.xx.1:40975: write: broken pipe”在告警主机中执行如下命令:
time curl -s --unix-socket /home/admin/ocp_agent/run/ocp_monagent.$(cat /home/admin/ocp_agent/run/ocp_monagent.pid).sock http://unix-socket-server/metrics/ob/basic > metric.log分析
metric.log文件存在类似如下结果:
可能原因
ob_query_rt(sql_type=“REDIS xxx”)指标的数据太多,处理过慢而导致 exporter 不可用。
影响版本
OceanBase 集群为 V4.2.5.1 及以上版本、OCP 为 V4.3.3 版本。
解决方法及规避方式
方式一:根本解决办法
升级 OCP 至 V4.3.4 及以上版本。
方式二:临时绕过方案
在告警主机上新建一个
tmp目录,将/home/admin/ocp_agent/conf/module_config/monitor_ob.yaml拷贝到tmp目录下。同时建议另外创建一个backup目录,对该配置文件进行备份。修改
monitor_ob.yaml的内容,在ob_query_rt的采集配置下增加disabled: true来停止该指标的采集,具体如下图所示。
在
tmp目录下创建一个push.py的执行推送的脚本,脚本内容如下:#!/usr/bin/python import base64 import httplib import json import sys def main(): host = sys.argv[1] userPswd = sys.argv[2] op = sys.argv[3].lower() c = httplib.HTTPConnection(host) header = { "Authorization": "Basic " + base64.b64encode(userPswd), "Content-Type": "application/json" } if op == "get": c.request("GET", "/api/v2/compute/hosts/moduleConfigChanges", None, header) else: fileName = sys.argv[4] content = "" if op == "set": content = sys.stdin.read() print("%s %s" % (op, fileName)) q = { "changes": [{ "operation": op, "scopeType": "global", "scope": "", "fileName": fileName, "content": content, }] } body = json.dumps(q) c.request("POST", "/api/v2/compute/hosts/moduleConfigChanges", body, header) r = c.getresponse() print(r.status) print(r.read()) if __name__ == '__main__': main()执行命令推送配置文件,需要将命令中的
ip、port、username、password替换成 OCP 的 IP、端口、用户名、密码。python push.py ip:port username:password set monitor_ob.yaml < monitor_ob.yaml在告警主机上确认 agent 的
monitor_ob.yaml中的内容是否已经更新。在 OCP 的 MetaDB 中执行如下命令,删除
compute_host_agent_module_config_change表中对应的记录,避免影响后续的 OCP-Agent 升级。delete from compute_host_agent_module_config_change where file_name in ('monitor_ob.yaml');