1. 前言
作为OceanBase的敏捷诊断工具,obdiag具有以下特点:
- 部署便捷:提供rpm包和OBD上部署的模式,都能够一键部署安装。用户可以选择将其部署到集群中任意一台能连接到各个节点的设备上,而不仅限于OBServer节点。
- 即开即用:使用过程中所依赖的python包都是自包含的,只需在部署机器上有python2或者python3环境即可。
- 集中收集:无需在每台服务器上分别部署,只需进行一次单点部署。需要时在部署机器上执行收集或分析命令即可使用
obdiag 1.2.1版本支持:
- 一键收集OB日志
- 一键收集AWR报告
- 一键收集主机信息
- 一键收集OB堆栈信息
- 一键收集(clog、slog解析后的日志)
- 一键收集perf信息(扁鹊图、perf火焰图、pstack火焰图)
- 一键收集并行SQL的执行详情信息
- 一键收集OBPROXY的日志待解锁功能
obdiag 1.3.0版本支持:
- 一键分析OB日志
obdiag 1.4.0版本支持:
- 一键集群巡检
obdiag 1.5.0版本支持:
- 一键全链路诊断
2. 安装部署使用
说明:方式一和方式二只需选择一种即可
2.1. 方式一:独立安装使用obdiag
2.1.1. obdiag部署
在线安装(可访问外网)
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
sudo yum install -y oceanbase-diagnostic-tool
source /usr/local/oceanbase-diagnostic-tool/init.sh
离线部署(不可访问外网)
obdiag工具可从OceanBase官网下载免费下载,下载链接
yum install -y oceanbase-diagnostic-tool*.rpm
source /usr/local/oceanbase-diagnostic-tool/init.sh
2.1.2. obdiag 配置
用户侧配置文件的默认路径是 ~/.obdiag/config.yml。可直接编辑配置文件或者通过 obdiag config <option> 命令快速生成配置。
obdiag config -h <db_host> -u <sys_user> [-p password] [-P port]
配置项说明如下:
参数名称 | 是否必须 | 说明 |
---|---|---|
db_host | 是 | OceanBase 集群 sys 租户的连接地址 |
sys_user | 是 | OceanBase 集群sys 租户的连接用户,例如 'root@sys' |
-p password | 否 | OceanBase 集群 sys 租户的连接密码,默认为空 |
-P port | 否 | OceanBas e集群 sys 租户的端口,默认为 2881 |
更多配置说明请参见文档: 链接
2.2. 方式二:OBD模式下安装使用obdiag
如果你的OceanBase集群是通过OBD安装部署的,并且OBD的版本大于2.5.0那么,你可以直接通过下面的方式使用。
2.1.1. 安装
-
安装OBD 2.5.0 及以上版本
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
sudo yum install -y ob-deploy
source /etc/profile.d/obd.sh -
安装obdiag工具
使用该命令可部署obdiag工具可在本机安装部署obdiag, (如果用户不安装直接使用也会走自动安装流程)
obdiag deploy
2.1.2. 使用
2.1.2.1. obd obdiag gather
使用该命令可调用obdiag工具进行OceanBase相关的诊断信息收集
obd obdiag gather <deploy name> <gather type> [options]
gather type包含:
- log:一键收集所属OceanBase集群的日志
- sysstat:一键收集所属OceanBase集群主机信息
- clog:一键收集所属OceanBase集群(clog日志)
- slog:一键收集所属OceanBase集群(slog日志)
- plan_monitor:一键收集所属OceanBase集群指定trace_id的并行SQL的执行详情信息
- perf:一键收集所属OceanBase集群的perf信息(扁鹊图、perf火焰图、pstack火焰图)
- obproxy_log:一键收集所属OceanBase集群所依赖的obproxy组件的日志
- all:一键统一收集所属OceanBase集群的诊断信息,包括收集OceanBase日志/主机信息/OceanBase堆栈信息/OceanBase OceanBase perf信息(扁鹊图、perf火焰图、pstack火焰图)
3. obdiag独立部署模式下使用体验
- 部署安装
在线部署(可访问外网的情况下可选择)
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
sudo yum install -y oceanbase-diagnostic-tool
source /usr/local/oceanbase-diagnostic-tool/init.sh
-
收集最近半小时内的OB集群日志
$obdiag gather log --since 30m
...
ZipFileInfo:
+----------------+-----------+
| Node | LogSize |
+================+===========+
| 11.162.218.126 | 12.231M |
+----------------+-----------+...
Gather Ob Log Summary:
+----------------+-----------+---------+--------+-----------------------------------------------------------------------------------------------------------+
| Node | Status | Size | Time | PackPath |
+================+===========+=========+========+===========================================================================================================+
| 11.162.218.126 | Completed | 12.231M | 5 s | /home/test/gather_pack_20231103110502/ob_log_192.168.1.111_20231103103500_20231103110600.zip. |
+----------------+-----------+---------+--------+-----------------------------------------------------------------------------------------------------------+
If you want to view detailed obdiag logs, please run:'obdiag display-trace --trace_id c5ca9bce-0279-3977-bb52-3ae0b35cd3a8'Trace ID: c5f1e526-79f5-11ee-81e3-00163e01c7ce
If you want to view detailed obd logs, please run: obd display-trace c5f1e526-79f5-11ee-81e3-00163e01c7ce -
收集指定时间的OB日志
obdiag gather log --from 2023-01-16 18:25:00 --to 2023-01-17 01:30:00
Gather Ob log Summary:
+-------------------+-----------+---------+--------+-----------------------------------------------------------------------+
| Node | Status | Size | Time | PackPath |
+===================+===========+=========+========+=======================================================================+
| xxx.xxx.xxx.xxx | Completed | 15.762K | 6 s | gather_pack_20230118002457/ob_log_xxx.xxx.xxx.xxx_20230118002458.zip |
+-------------------+-----------+---------+--------+-----------------------------------------------------------------------+ -
收集all
$obdiag gather all
...
ZipFileInfo:
+----------------+-----------+
| Node | LogSize |
+================+===========+
| 11.162.218.126 | 17.469M |
+----------------+-----------+...
Gather Ob Log Summary:
+----------------+-----------+---------+--------+-----------------------------------------------------------------------------------------------------------+
| Node | Status | Size | Time | PackPath |
+================+===========+=========+========+===========================================================================================================+
| 11.162.218.126 | Completed | 17.469M | 6 s | /home/test/gather_pack_20231103111342/ob_log_192.168.1.111_20231103104340_20231103111440.zip |
+----------------+-----------+---------+--------+-----------------------------------------------------------------------------------------------------------+...
Gather Sysstat Summary:
+----------------+-----------+----------+--------+---------------------------------------------------------------------------------------------+
| Node | Status | Size | Time | PackPath |
+================+===========+==========+========+=============================================================================================+
| 11.162.218.126 | Completed | 865.705K | 2 s | /home/test/gather_pack_20231103111342/sysstat_192.168.1.111_20231103111348.zip |
+----------------+-----------+----------+--------+---------------------------------------------------------------------------------------------+...
Gather Perf Summary:
+----------------+-----------+---------+--------+------------------------------------------------------------------------------------------+
| Node | Status | Size | Time | PackPath |
+================+===========+=========+========+==========================================================================================+
| 11.162.218.126 | Completed | 12.530K | 6 s | /home/test/gather_pack_20231103111342/perf_192.168.1.111_20231103111351.zip |
+----------------+-----------+---------+--------+------------------------------------------------------------------------------------------+...
Gather Ob stack Summary:
+----------------+-----------+---------+--------+----------------------------------------------------------------------------------------------+
| Node | Status | Size | Time | PackPath |
+================+===========+=========+========+==============================================================================================+
| 11.162.218.126 | Completed | 11.567K | 5 s | /home/test/gather_pack_20231103111342/obstack2_192.168.1.111_20231103111358.zip |
+----------------+-----------+---------+--------+----------------------------------------------------------------------------------------------+...
If you want to view detailed obdiag logs, please run:'obdiag display-trace --trace_id afb5d4ad-b723-38bc-a660-d050c94132a3'
Trace ID: fc37da72-79f6-11ee-a367-00163e01c7ce
If you want to view detailed obd logs, please run: obd display-trace fc37da72-79f6-11ee-a367-00163e01c7ce
4. OBD模式下obdiag使用
参见OBD官网文档: OceanBase分布式数据库-海量数据 笔笔算数
|-----|-------------------------------------------------|
| 第一篇 | 如何修炼成"神医"------《OceanBase诊断系列》之一 |
| 第二篇 | 走进SQL审计视图------《OceanBase诊断系列》之二 |
| 第三篇 | 一键操作快捷诊断工具obdiag收集诊断信息实践------《OceanBase诊断系列》之三 |