If OceanBase Diagnostic Tool (obdiag) is independently deployed, you can run this command to analyze OceanBase Database logs to identify errors that have occurred.
If your OceanBase cluster is deployed by using OceanBase Deployer (obd), you can run obdiag commands on obd to collect diagnostic information of the cluster. For more information about the commands, see obdiag commands.
Syntax
obdiag analyze log [options]
You can run this command to analyze the logs of an OceanBase cluster online, or specify the --files option to enable offline analysis.
The following table describes the options.
| Option | Required? | Data type | Default value | Description |
|---|---|---|---|---|
| --from | No | string | Empty | The start time of log collection in the yyyy-mm-dd hh:mm:ss format. |
| --to | No | string | Empty | The end time of log collection in the yyyy-mm-dd hh:mm:ss format. |
| --since | No | string | Empty | The most recent period of time for log collection, in the format of <n> <m|h|d>, where n specifies the time value, m represents "minute". h represents "hour", and d represents "day". For example, 30m specifies to analyze logs of the last 30 minutes. |
| --scope | No | string | all | The type of logs of the OceanBase cluster to be analyzed. Valid values: observer, election, rootservice, and all. |
| --grep | No | string | Empty | The search keyword. |
| --store_dir | No | string | The current path where the command is executed | The local path where the results are stored. |
| --log_level | No | string | WARN | The level of logs of the OceanBase cluster to be analyzed. Valid values indicating log levels in ascending order of severity: DEBUG, TRACE, INFO, WDIAG, WARN, EDIAG, and ERROR. Logs of the specified level and higher are analyzed. |
| --files | No | string | Empty | If you specify the --files option, the offline log analysis mode is enabled. In offline analysis mode, you must specify the name or path of the log file of the OceanBase cluster, but you do not need to specify the --from, --to, --since, or --ob_install_dir option. |
| -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. |
Note
- In online analysis mode, the runtime status of an OceanBase cluster is analyzed, and the logs are distributed on all OBServer nodes of the cluster.
- In offline analysis mode, which is enabled by specifying the
--filesoption, obdiag analyzes the logs of OBServer nodes that are already collected to the server where obdiag is deployed.
Examples
Method 1: Use the command 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.
Example of online log analysis
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.xx.2 \ --config obcluster.servers.global.ssh_username=test \ --config obcluster.servers.global.ssh_password=****** \ --config obcluster.servers.global.home_path=/home/admin/oceanbaseThe 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'Quick analysis of logs of a recent period of time
# Analyze the logs of the last hour online. When you run this command, obdiag pulls and analyzes the logs of the last hour from the remote host to diagnose the errors that have occurred. obdiag analyze log --since 1h \ --config obcluster.servers.nodes[0].ip=xx.xx.xx.1 \ --config obcluster.servers.nodes[1].ip=xx.xx.xx.xx.2 \ --config obcluster.servers.nodes[2].ip=xx.xx.xx.xx.3 \ --config obcluster.servers.global.home_path=/home/admin/oceanbase # Analyze the logs of the last hour online. When you run this command, obdiag pulls and analyzes the logs of the last hour from the remote host to diagnose the errors that have occurred. # Specify the connection information of the `sys` tenant so that obdiag automatically obtains the IP addresses of all nodes in the cluster. 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 # Analyze the logs of the last 30 minutes online. When you run this command, obdiag pulls and analyzes the logs of the last 30 minutes from the remote host to diagnose the errors that have occurred. # Specify the connection information of the `sys` tenant so that obdiag automatically obtains the IP addresses of all nodes in the cluster. 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/oceanbaseExample of offline log analysis
$ 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'Analyze a specified OBServer log file offline
# Analyze a specified log file offline obdiag analyze log --files observer.log.20230831142211247
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.
Example of online log analysis
obdiag analyze log --from "2023-10-08 10:25:00" --to "2023-10-08 11:30:00"Quick analysis of logs of a recent period of time
# Analyze the logs of the last hour online. When you run this command, obdiag pulls and analyzes the logs of the last hour from the remote host to diagnose the errors that have occurred. obdiag analyze log --since 1h # Analyze the logs of the last 30 minutes online. When you run this command, obdiag pulls and analyzes the logs of the last 30 minutes from the remote host to diagnose the errors that have occurred. obdiag analyze log --since 30mAnalyze a specified OBServer log file offline
# Analyze a specified log file offline obdiag analyze log --files observer.log.20230831142211247