If OceanBase Diagnostic Tool (obdiag) is independently deployed, you can specify the observer.topsql scenario in the obdiag gather scene run command to collect top SQL statements of a cluster.
Note
The SQL statement information collected by this command is often required when you seek help in troubleshooting from the OceanBase community forum or OceanBase Technical Support.
Syntax
obdiag gather scene run --scene=observer.topsql [options]
The following table describes the options.
| Option | Required | Data type | Default value | Description |
|---|---|---|---|---|
| --scene | Yes | string | Empty | The name of the scenario. You can run the obdiag gather scene list command to view the scenarios supported by the current version. |
| --store_dir | No | string | The current path where the command is executed | The local path where the results are stored. |
| -c | No | string | ~/.obdiag/config.yml |
The path of the configuration file. |
| --inner_config | No | string | Empty | The configurations of obdiag. |
| --config | No | string | Empty | The configurations of the cluster diagnosed by obdiag, in the format of --config key1=value1 --config key2=value2.
NoteFor information about the parameters supported by this option, see Configure obdiag. |
Examples
Method 1: Use the command out-of-the-box without a configuration file
# Collect top SQL statements of a cluster
obdiag gather scene run --scene=observer.topsql \
--config db_host=xx.xx.xx.xx \
--config db_port=xxxx \
--config tenant_sys.user=root@sys \
--config tenant_sys.password=***
Method 2: Use the command with a configuration file
Make sure that you have configured the login information of the target nodes in the config.yml configuration file of obdiag. For more information, see Configure obdiag.
# Collect top SQL statements of a cluster
obdiag gather scene run --scene=observer.topsql
Results
The command generates a folder in the specified directory. A sample folder name is obdiag_gather_pack_20240808105846.
#tree
.
└── sql_result.txt # The top SQL statements of the cluster.
Cases
When a backup issue occurs, you can run the following command to collect the information required for diagnostics. Then, you can post the information on the OceanBase community forum or send it to OceanBase Technical Support.
obdiag gather scene run --scene=observer.topsql \
--config db_host=xx.xx.xx.xx \
--config db_port=xxxx \
--config tenant_sys.user=root@sys \
--config tenant_sys.password=***