OceanBase 敏捷诊断工具(OceanBase Diagnostic Tool,简称obdiag)是一款源代码开源敏捷黑屏诊断工具,可以对OceanBase集群进行一键集群巡检、一键分析以及一键诊断信息收集。

obdiag 有五大核心功能,分别是: 一键集群巡检、一键信息收集、一键分析、一键根因分析、一键集群洞察。
obdiag 具有以下特点:


敏捷诊断工县obdiag 采用集中式采集将分散在各个节点的信息收集到obdiag所在节点进行统一分析处理。



用 户诊断场景更新可能很快,obdiag直接热更新即刻更新场景。

有3种安装方式:联网在线独立安装、离线独立安装、obd方式安装,如下:



cd /root rpm -ivh oceanbase-diagnostic-tool-3.6.0-22025080417.el7.x86_64.rpm source /opt/oceanbase-diagnostic-tool/init.sh
安装包需要到 下载中心 https://www.oceanbase.com/softwarecenter 进行下载
配置 obdiag 用户侧配置文件可通过
obdiag config -h <db_host> -u <sys_user> [-p password] [-P port]
命令快速生成或者直接编辑配置文件,文件的默认路径是
~/.obdiag/config.yml
,其样板文件位于
~/.obdiag/example
。即一条命令生成配置文件
obdiag config -h127.0.0.1 -uroot@sys -P2881
交互配置的时候填入信息如下:
username
为root,
home_path
为/home/admin/oceanbase/observer/,obproxy:输入N。其余回车键保持默认即可,输出如下:
[root@iZbp13y46iroifwaco984rZ ~]# obdiag config -h127.0.0.1 -uroot@sys -P2881 obdiag version: 3.6.0 Please enter the following configuration !!! Enter your oceanbase host ssh username (default:''): root Enter your use password or key file (0:use password; 1:use key file) default: 0: Enter your oceanbase host ssh password (default:''): Enter your oceanbase host ssh_port (default:'22'): Enter your oceanbase install home_path (default:'/root/observer'): /home/admin/oceanbase/observer/ Enter your need config obproxy [y/N] (default:'N'): N Node information has been rewritten to the configuration file /root/.obdiag/config.yml, and you can enjoy the journey ! Trace ID: 08065136-767f-11f0-bbc2-00163e30512b If you want to view detailed obdiag logs, please run: obdiag display-trace 08065136-767f-11f0-bbc2-00163e30512b
如果是生成多个集群配置文件,按以下步骤:

使用 obdiag display 命令可帮助洞察 OceanBase 数据库相关的信息。
obdiag display scene list
obdiag display scene run --scene=observer.cluster_info
obdiag display scene run --scene=observer.server_info
obdiag display scene run --scene=observer.memory
obdiag display scene run --scene=observer.cpu
obdiag display scene run --scene=observer.topsql --env tenant_name=test --env mtime=10
17个大类,120+小类的巡检项

--查看所有的巡检套餐 obdiag check list

obdiag check run
执行全量巡检之后,会生成一份巡检结果,名为:./check_report/obdiag_check_report_observer_YYYY-MM-HH-MM-xx-xx.table
cat ./check_report/obdiag_check_report_observer*
obdiag check run cases=sysbench_free 或 obdiag check run cases=sysbench_run
obdiag check run case=sys_run
obdiag check run cases=column_storage_poc

--一键日志分析 默认是30分钟 obdiag analyze log --在线分析最近10分钟的日志,该指令执行的时候会从远程主机上拉取最近10分钟的日志进行分析,诊断出现过的错误 obdiag analyze log --since 10m --一键日志分析指定时间区间的日志 obdiag analyze log --from "2025-8-11 16:05:00" --to "2025-8-11 16:10:00" --一键离线分析本地文件夹中所有observer的日志 obdiag analyze log --files /root/obdiag_analyze_pack_20250811162557/ --一键离线分析本地中指定一个文件的日志 obdiag analyze log --files /root/obdiag_analyze_pack_20250811162557/result_details.txt
obdiag analyze memory

obdiag rca list
obdiag rca run --scene=<scene_name>
scene_name
包含如下:
obdiag rca run --scene=major_hold 参数说明: major_hold:一键卡合并诊断。
obdiag rca run --scene=lock_conflict --env tenant_name=sys
查看根因分析结果
cat ./obdiag_rca/obdiag_major_hold_*/record.table
obdiag rca run --scene=disconnection
obdiag rca run --scene=ddl_disk_full --env tenant_name=test1 --env table_name=t555 --env action_type=add_index --env index_name=k1 --env database_name=xxx
如果使用OMS相关诊断时(--scene 名字以oms开头)需要配置OMS集群信息,配置文件默认位置:~/.obdiag/config.yml,也可以通过--config 选项传递配置。

obdiag gather plan_monitor
通过
obdiag gather -h
可查看所有的收集功能。
obdiag gather log --since 1h
obdiag gather sysstat
基于场景的诊断信息收集是上面的常规诊断信息收集的排列组合,用于快速收集具体场景的诊断问题排查所需要的全部信息。
--查看当前支持的场景 obdiag gather scene list
obdiag gather scene run --scene=observer.base
io问题信息收集,默认不需要添加任何参数的话收集最近30分钟的信息
obdiag gather scene run --scene=observer.io
内存问题信息收集,默认不需要添加任何参数的话收集最近30分钟的信息
obdiag gather scene run --scene=observer.memory
obdiag gather perf
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69963491/viewspace-3093206/ ,如需转载,请注明出处,否则将追究法律责任。