This topic describes how to use OceanBase Diagnostic Tool (obdiag) that is independently deployed to collect and display the information about slow SQL statements in a cluster in a terminal.
Syntax
obdiag display scene run --scene=observer.slowsql [options]
The following table describes the options.
| Option | Required? | Data type | Default value | Description |
|---|---|---|---|---|
| -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. |
| --env | Yes | string | Empty | Additional parameters required for the obdiag display command, in the format of --env db_connect='-h127.0.0.1 -P2881 -utest@test -p****** -Dtest' --env mtime=10'. |
Note
In the --env option, db_connect='-h127.0.0.1 -P2881 -utest@test -p****** -Dxxxx' indicates the connection string of the business tenant.
In the --env option, mtime indicates the period for which slow SQL statements are to be queried, in minutes.
Examples
Method 1: Use obdiag out-of-the-box without a configuration file
Note
For more information about the parameters used in the command in this section, see Configure obdiag.
# The --env option is passed to specify the connection string of the tenant whose slow SQL statements within the last 10 minutes are to be queried.
$ obdiag display scene run --scene=observer.slowsql --env db_connect='-h127.0.0.1 -P2881 -utest@test -p****** -Dtest' --env mtime=10 \
--config db_host=xx.xx.xx.xx \
--config db_port=xxxx \
--config tenant_sys.user=root@sys \
--config tenant_sys.password=***
# The --env option is not passed to specify the connection string of the tenant whose slow SQL statements are to be queried. By default, the slow SQL statements of all tenants are queried from the sys tenant.
obdiag display scene run --scene=observer.slowsql --env mtime=10 \
--config db_host=xx.xx.xx.xx \
--config db_port=xxxx \
--config tenant_sys.user=root@sys \
--config tenant_sys.password=***
Method 2: Use obdiag with a configuration file
Before you use obdiag, 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.
# The --env option is passed to specify the connection string of the tenant whose slow SQL statements are to be queried.
obdiag display scene run --scene=observer.slowsql --env db_connect='-h127.0.0.1 -P2881 -utest@test -p****** -Dtest' --env mtime=10
# The --env option is not passed to specify the connection string of the tenant whose slow SQL statements are to be queried. By default, the slow SQL statements of all tenants are queried from the sys tenant.
obdiag display scene run --scene=observer.slowsql --env mtime=10