If OceanBase Diagnostic Tool (obdiag) is independently deployed, you can specify the observer.perf_sql scenario in the obdiag gather scene run command to collect the information required for analyzing SQL statement execution errors. The command helps address the pain point in collecting information on distributed nodes.
Syntax
obdiag gather scene run --scene=observer.perf_sql [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 obd obdiag gather scene list command to view the scenarios supported by the current version. |
| --env | Yes | string | Empty | Additional parameters to be collected for this scenario. |
| --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. |
| --temp_dir | No | string | /tmp |
The directory where temporary files generated by the remote node during log collection are stored. |
| --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 information for SQL statement execution errors. If you do not specify any other options, the command collects the information of the last 30 minutes.
obdiag gather scene run --scene=observer.perf_sql --env "{db_connect='-h127.0.0.1 -P2881 -utest@test -p****** -Dtest', trace_id='Yxx'}" \
--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.ssh_username=test \
--config obcluster.servers.global.ssh_password=****** \
--config obcluster.servers.global.home_path=/home/admin/oceanbase
Method 2: Use the command with a configuration file
Before you run the command, make sure that you have configured the logon information of the target nodes in the config.yml configuration file of obdiag. For more information, see Configure obdiag.
# Collect information for SQL statement execution errors. If you do not specify any other options, the command collects the information of the last 30 minutes.
obdiag gather scene run --scene=observer.perf_sql --env "{db_connect='-h127.0.0.1 -P2881 -utest@test -p****** -Dtest', trace_id='Yxx'}"
Results
The command generates a folder in the specified directory. A sample folder name is obdiag_gather_pack_20240808105846.
#tree
.
├── ob_log_xx.xx.xx.xx_20240611190059_20240611193159.zip # The logs of OBServer nodes.
├── resources
│ └── web
│ ├── bootstrap.min.css
│ ├── bootstrap.min.js
│ ├── jquery-3.2.1.min.js
│ └── popper.min.js
├── result_summary.txt
├── sql_result.txt # The SQL statement execution results required for analyzing SQL statement execution errors.
└── sql_plan_monitor_report.html # The diagnostic report for SQL statement execution errors.
Cases
When an error occurs during the execution of an SQL statement, 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.perf_sql --env "{db_connect='-h127.0.0.1 -P2881 -utest@test -p****** -Dtest', trace_id='Yxx'}" \
--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.ssh_username=test \
--config obcluster.servers.global.ssh_password=****** \
--config obcluster.servers.global.home_path=/home/admin/oceanbase