This article applies to the scenario of independent deployment of obdiag. Use the obdiag analyze log command to analyze OceanBase logs and find out the error information that has occurred.
If it is a cluster deployed by obd, you can directly collect information on the selected cluster through the obd side diagnostic command group.
Instructions for use
obdiag analyze log [options]
Use this command to analyze OceanBase cluster logs online with one click, or enable offline analysis mode through --files.
The options are explained below:
Option name |
Is it required |
Data type |
Default value |
Description |
|---|---|---|---|---|
| --from | No | string | Default is empty | Starting point of analysis time range, format: yyyy-mm-dd hh:mm:ss. |
| --to | No | string | Default is empty | The end of the analysis time range, format: yyyy-mm-dd hh:mm:ss. |
| --since | No | string | 30m |
The time range relative to the current time, format: <n><m|h|d>, where n represents the time number to be entered, m represents minutes, h represents hours, and d represents days, such as 1h represents the last hour. |
| --scope | No | string | all | The log type to be analyzed, optional values are observer, election, rootservice, all. |
| --grep | No | string | Default is empty | Keyword filtering, can be specified multiple times. |
| --log_level | No | string | Default is empty | Only logs with a level no lower than this level will be analyzed. Configurable values are DEBUG, TRACE, INFO, WDIAG, WARN, EDIAG, ERROR. |
| --files | No | string | Default is empty | In offline analysis mode, specify a local log file or directory; after specifying, ignore --from, --to, --since and analyze from local files. |
| --store_dir | No | string | Current directory | Analysis result storage path. |
| --temp_dir | No | string | /tmp |
The temporary file storage directory of the remote node during online analysis. |
| --tenant_id | No | string | Default is empty | Filter error statistics by tenant. You can fill in the tenant name or tenant_id:xxx (such as tenant_id:1001); if not filled in, all tenants will be counted. |
| -c | No | string | ~/.obdiag/config.yml |
Configuration file path. |
| --inner_config | No | string | Default is empty | obdiag Self-configuration, format: --inner_config key=value. |
| --config | No | string | Default is empty | Cluster configuration, format: --config key1=value1 --config key2=value2. See obdiag configuration for details. |
| --config_password | No | string | Default is empty | obdiag When using an encrypted configuration file, you need to pass in the corresponding password through this option. For details, see Configuration File Encryption. |
Description
- The online analysis referred to in this article refers to the online running status of the OceanBase cluster, and the logs are distributed on each OBServer node.
- The offline analysis mode referred to in this article is that when the
--filesparameter is passed, the OBServer logs that have been collected on the obdiag deployment machine can be analyzed.
Usage example
Method 1: Use without configuration file (out of the box)
- Online analysis log example:
obdiag analyze log --from "2023-10-08 10:25:00" --to "2023-10-08 11:30:00" \
--config obcluster.servers.nodes[0].ip=xx.xx.xx.1 \
--config obcluster.servers.nodes[1].ip=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
The output is as follows:
...
FileListInfo:
+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Node | LogList |
+================+=======================================================================================================================================================================================================================+
| xx.xx.xx.xx | ['observer.log.20231008104204260', 'observer.log.20231008111305072', 'observer.log.20231008114410668', 'observer.log.wf.20231008104204260', 'observer.log.wf.20231008111305072', 'observer.log.wf.20231008114410668'] |
+----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
...
Analyze OceanBase Online Log Summary:
+----------------+-----------+------------------------------------------------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------+---------+
| Node | Status | FileName | ErrorCode | Message | Count |
+================+===========+==============================================================================+=============+===============================================================================================================================+=========+
| xx.xx.xx.xx | Completed | analyze_pack_20231008171201/xx_xx_xx_xx/observer.log.20231008104204260 | -5006 | You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use | 2 |
+----------------+-----------+------------------------------------------------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------+---------+
| xx.xx.xx.xx | Completed | analyze_pack_20231008171201/xx_xx_xx_xx/observer.log.20231008111305072 | -5006 | You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use | 8 |
+----------------+-----------+------------------------------------------------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------+---------+
| xx.xx.xx.xx | Completed | analyze_pack_20231008171201/xx_xx_xx_xx/observer.log.20231008114410668 | -5006 | You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use | 10 |
+----------------+-----------+------------------------------------------------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------+---------+
| xx.xx.xx.xx | Completed | analyze_pack_20231008171201/xx_xx_xx_xx/observer.log.20231008114410668 | -4009 | IO error | 20 |
+----------------+-----------+------------------------------------------------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------+---------+
For more details, please run cmd 'cat analyze_pack_20231008171201/result_details.txt'
```* Quickly analyze the logs of the recent period:
```shell
# Online: analyze the last hour of logs pulled from remote hosts for errors
obdiag analyze log --since 1h \
--config obcluster.servers.nodes[0].ip=xx.xx.xx.1 \
--config obcluster.servers.nodes[1].ip=xx.xx.xx.2 \
--config obcluster.servers.nodes[2].ip=xx.xx.xx.3 \
--config obcluster.servers.global.home_path=/home/admin/oceanbase
# Online: analyze the last hour of logs pulled from remote hosts for errors
# Provide sys tenant connection; obdiag resolves cluster node IP addresses
obdiag analyze log --since 1h \
--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
# Online: analyze last 30 minutes of logs from remotes for errors
# Provide sys tenant connection; obdiag resolves cluster node IP addresses
obdiag analyze log --since 30m \
--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
```* Offline analysis log example
```shell
$ ls -lh test/
-rw-r--r-- 1 admin staff 256M Oct 8 17:24 observer.log.20231008104204260
-rw-r--r-- 1 admin staff 256M Oct 8 17:24 observer.log.20231008111305072
-rw-r--r-- 1 admin staff 256M Oct 8 17:24 observer.log.20231008114410668
-rw-r--r-- 1 admin staff 18K Oct 8 17:24 observer.log.wf.20231008104204260
-rw-r--r-- 1 admin staff 19K Oct 8 17:24 observer.log.wf.20231008111305072
-rw-r--r-- 1 admin staff 18K Oct 8 17:24 observer.log.wf.20231008114410668
$ obdiag analyze log --files test/
Analyze OceanBase Offline Log Summary:
+-----------+-----------+-----------------------------------------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------+---------+
| Node | Status | FileName | ErrorCode | Message | Count |
+===========+===========+=======================================================================+=============+===============================================================================================================================+=========+
| 127.0.0.1 | Completed | analyze_pack_20231008172144/127_0_0_1_/observer.log.20231008104204260 | -5006 | You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use | 2 |
+-----------+-----------+-----------------------------------------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------+---------+
| 127.0.0.1 | Completed | analyze_pack_20231008172144/127_0_0_1_/observer.log.20231008111305072 | -5006 | You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use | 8 |
+-----------+-----------+-----------------------------------------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------+---------+
| 127.0.0.1 | Completed | analyze_pack_20231008172144/127_0_0_1_/observer.log.20231008114410668 | -5006 | You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use | 10 |
+-----------+-----------+-----------------------------------------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------+---------+
| 127.0.0.1 | Completed | analyze_pack_20231008172144/127_0_0_1_/observer.log.20231008114410668 | -4009 | IO error | 20 |
+-----------+-----------+-----------------------------------------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------+---------+
For more details, please run cmd 'cat analyze_pack_20231008172144/result_details.txt'
```* Offline analysis of specified observer logs:
```shell
# Offline: analyze the given log file(s)
obdiag analyze log --files observer.log.20230831142211247
```* Filter error statistics by tenant (only errors for the specified tenant are displayed):
```shell
# Filter by tenant name (online)
obdiag analyze log --since 1h --tenant_id my_tenant
# Filter by tenant ID (format tenant_id:xxx)
obdiag analyze log --since 1h --tenant_id tenant_id:1001
# Offline analysis can filter by tenant too
obdiag analyze log --files test/ --tenant_id tenant_id:1001
Method 2: Use with configuration file
You need to ensure that the login information of the node to be collected has been configured in the obdiag configuration file ~/.obdiag/config.yml. For related detailed configuration introduction, see obdiag configuration. .
- Online analysis log example:
obdiag analyze log --from "2023-10-08 10:25:00" --to "2023-10-08 11:30:00"
```* Quickly analyze the logs of the recent period:
```shell
# Online: analyze the last hour of logs pulled from remote hosts for errors
obdiag analyze log --since 1h
# Online: analyze last 30 minutes of logs from remotes for errors
obdiag analyze log --since 30m
```* Offline analysis of specified observer logs:
```shell
# Offline: analyze the given log file(s)
obdiag analyze log --files observer.log.20230831142211247
