---
title: "clog/slog收集 - 敏捷诊断工具 V2.4.0 | OceanBase 文档中心"
description: clog/slog收集 本文适用于独立部署 obdiag 的场景，使用 obdiag gather clog 会通过 obdiag 工具调用收集机器上的 ob_admin 解析 clog 文件，并对所选时间范围内的 clog 进行一键收集。使用 obdiag gather slog 会通过 obdiag 工具调用收集…
image: https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*OSPzQ6GUQF4AAAAAQHAAAAgAeiGDAQ/original
---
切换语言

- 中文站 - 简体中文
- International - English
- 日本站 - 日本語

文档反馈![](https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*5ZXST55u540AAAAAAAAAAAAADiGDAQ/original) 敏捷诊断工具V 2.4.0

# clog/slog收集

更新时间：2026-04-13 17:11:17

[编辑](https://github.com/oceanbase/odt-doc/edit/V2.4.0/zh-CN/400.gather/100.normal/110.gather_clog_slog.md)  

本文适用于独立部署 obdiag 的场景，使用 `obdiag gather clog` 会通过 obdiag 工具调用收集机器上的 ob_admin 解析 clog 文件，并对所选时间范围内的 clog 进行一键收集。使用 `obdiag gather slog` 会通过 obdiag 工具调用收集机器上的 ob_admin 解析 slog 文件，并对所选时间范围内的 slog 进行一键收集。

如果是 obd 部署的集群，可直接通过 obd 侧诊断命令组对所选集群进行信息收集，详细命令可参考 [诊断工具命令组](https://www.oceanbase.com/docs/community-obd-cn-10000000002049483)。

## 使用说明

### obdiag gather clog

```shell
obdiag gather clog [options]

```

选项说明如下：

| 选项名 | 是否必选 | 数据类型 | 默认值 | 说明 |
| --- | --- | --- | --- | --- |
| --from | 否 | string | 默认为空 | 日志收集的开始时间，格式为: `yyyy-mm-dd hh:mm:ss`。   #### 说明    若使用的 obdiag 为 V2.0.0 之前版本，配置该选项时无需加引号，否则会报错。V2.0.0 及之后版本不再限制配置该选项时是否加引号。 |
| --to | 否 | string | 默认为空 | 日志收集的结束时间，格式为: `yyyy-mm-dd hh:mm:ss`。   #### 说明    若使用的 obdiag 为 V2.0.0 之前版本，配置该选项时无需加引号，否则会报错。V2.0.0 及之后版本不再限制配置该选项时是否加引号。 |
| --since | 否 | string | 默认为空 | 日志收集最近的某段时间，格式为: `<n> <m\|h\|d>`，其中，n 表示待输入的时间数字，m 表示分钟，h 表示小时，d 表示天，例如 `30m` 表示收集最近 30 分钟的日志。 |
| --encrypt | 否 | string | false | 指定回传的文件是否加密，可配置为 true 或 false，默认为 false。 |
| --store_dir | 否 | string | 默认为命令执行的当前路径 | 存储结果的本地路径。 |
| -c | 否 | string | `~/.obdiag/config.yml` | 配置文件路径。 |
| --inner_config | 否 | string | 默认为空 | obdiag 自用的配置。 |
| --config | 否 | string | 默认为空 | obdiag 被诊断集群的配置，固定样式：--config key1=value1 --config key2=value2。 |

### obdiag gather slog

```shell
obdiag gather slog [options]

```

选项说明如下：

| 选项名 | 是否必选 | 数据类型 | 默认值 | 说明 |
| --- | --- | --- | --- | --- |
| --from | 否 | string | 默认为空 | 日志收集的开始时间，格式为: `yyyy-mm-dd hh:mm:ss`。 |
| --to | 否 | string | 默认为空 | 日志收集的结束时间，格式为: `yyyy-mm-dd hh:mm:ss`。 |
| --since | 否 | string | 默认为空 | 日志收集最近的某段时间，格式为: `<n> <m\|h\|d>`，其中，n 表示待输入的时间数字，m 表示分钟，h 表示小时，d 表示天，例如 `30m` 表示收集最近 30 分钟的日志。 |
| --encrypt | 否 | string | false | 指定回传的文件是否加密，可配置为 true 或 false，默认为 false。 |
| --store_dir | 否 | string | 默认为命令执行的当前路径 | 存储结果的本地路径。 |
| -c | 否 | string | `~/.obdiag/config.yml` | 配置文件路径。 |
| --inner_config | 否 | string | 默认为空 | obdiag 自用的配置。 |
| --config | 否 | string | 默认为空 | obdiag 被诊断集群的配置，固定样式：--config key1=value1 --config key2=value2。 |

## 使用示例

### 方式一：无配置文件使用（开箱即用）

#### 说明

本节命令中使用的详细配置介绍可参见 [obdiag 配置](https://www.oceanbase.com/docs/common-obdiag-cn-1000000001326824)。

- 收集 clog 日志

  ```shell
  obdiag gather clog --from "2023-01-16 18:25:00" --to "2023-01-17 01:30:00" \
      --config obcluster.servers.nodes[0].ip=xx.xx.xx.1 \
      --config obcluster.servers.nodes[1].ip=xx.xx.xx.xx.2 \
      --config obcluster.servers.global.ssh_username=test \
      --config obcluster.servers.global.ssh_password=****** \
      --config obcluster.servers.global.home_path=/home/admin/oceanbase

  ```

  输出如下：

  ```shell
  Gather clog Summary:
  +-------------------+-----------+---------+--------+-----------------------------------------------------------------------+
  | Node              | Status    | Size    | Time   | PackPath                                                              |
  +===================+===========+=========+========+=======================================================================+
  | xxx.xxx.xxx.xxx   | Completed | 15.762K | 6 s    | gather_pack_20230118002457/obadmin_xxx.xxx.xxx.xxx_20230118002458.zip |
  +-------------------+-----------+---------+--------+-----------------------------------------------------------------------+

  ```
 - 收集 slog 日志

  ```shell
  obdiag gather slog --from "2023-01-16 18:25:00" --to "2023-01-17 01:30:00" \
      --config obcluster.servers.nodes[0].ip=xx.xx.xx.1 \
      --config obcluster.servers.nodes[1].ip=xx.xx.xx.xx.2 \
      --config obcluster.servers.global.ssh_username=test \
      --config obcluster.servers.global.ssh_password=****** \
      --config obcluster.servers.global.home_path=/home/admin/oceanbase

  ```

  输出如下：

  ```shell
  Gather slog Summary:
  +-------------------+-----------+---------+--------+-----------------------------------------------------------------------+
  | Node              | Status    | Size    | Time   | PackPath                                                              |
  +===================+===========+=========+========+=======================================================================+
  | xxx.xxx.xxx.xxx   | Completed | 15.762K | 6 s    | gather_pack_20230118002457/obadmin_xxx.xxx.xxx.xxx_20230118002458.zip |
  +-------------------+-----------+---------+--------+-----------------------------------------------------------------------+

  ```
 - 被收集的节点配置过免密

  ```bash
  obdiag gather slog \
      --config obcluster.servers.nodes[0].ip=xx.xx.xx.1 \
      --config obcluster.servers.nodes[1].ip=xx.xx.xx.xx.2 \
      --config obcluster.servers.global.home_path=/home/admin/oceanbase

  ```
 - 被收集的节点 ssh 登陆的账号密码不同

  ```bash
  obdiag gather slog \
      --config obcluster.servers.nodes[0].ip=xx.xx.xx.1 \
      --config obcluster.servers.nodes[0].ssh_username=test1 \
      --config obcluster.servers.nodes[0].ssh_password=****** \
      --config obcluster.servers.nodes[0].home_path=/home/test2/oceanbase
      --config obcluster.servers.nodes[1].ip=xx.xx.xx.xx.2
      --config obcluster.servers.nodes[1].ssh_username=test2 \
      --config obcluster.servers.nodes[1].ssh_password=****** \
      --config obcluster.servers.nodes[1].home_path=/home/test2/oceanbase

  ```
 - 提供 sys 租户的连接信息，让 obdiag 自动帮你获取集群各节点的 ip 地址并收集该集群全部节点的信息

  ```bash
  obdiag gather slog \
      --config db_host=xx.xx.xx.xx \
      --config db_port=xxxx \
      --config tenant_sys.user=root@sys \
      --config tenant_sys.password=*** \
      --config obcluster.servers.global.home_path=/home/admin/oceanbase

  ```

### 方式二：有配置文件使用

需要确保已经在 obdiag 配置文件 `config.yml` 中配置好需要收集节点的登录信息。相关的详细配置介绍，参见 [obdiag 配置](https://www.oceanbase.com/docs/common-obdiag-cn-1000000001326824)。

  ```shell
  obdiag gather clog --from "2023-01-16 18:25:00" --to "2023-01-17 01:30:00"

  ```shell
  obdiag gather slog --from "2023-01-16 18:25:00" --to "2023-01-17 01:30:00"

  ```

 上一篇 下一篇 ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
