This article applies to the scenario of independently deploying obdiag. Use the obdiag analyze memory command to analyze the logs of the OceanBase cluster and generate a memory analysis report based on the memory information printed in the logs.
Description
Since obdiag V4.2.0, the display style of memory analysis results has been optimized, and the HTML template indentation and chart parameter readability have been improved.
If it is a cluster deployed by obd, you can directly analyze the selected cluster through the obd side diagnostic command group.
Instructions for use
obdiag analyze memory [options]
Use this command to analyze the logs of the OceanBase cluster online with one click and generate a memory analysis report based on the memory information printed in the logs. Or turn on 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 | The start time of log collection, the format is: yyyy-mm-dd hh:mm:ss.
ExplanationIf the obdiag used is a version before V2.0.0, there is no need to add quotation marks when configuring this option, otherwise an error will be reported. V2.0.0 and later versions no longer limit whether to include quotes when configuring this option. |
| --to | No | string | Default is empty | The end time of log collection, the format is: yyyy-mm-dd hh:mm:ss.
ExplanationIf the obdiag used is a version before V2.0.0, there is no need to add quotation marks when configuring this option, otherwise an error will be reported. V2.0.0 and later versions no longer limit whether to include quotes when configuring this option. |
| --since | No | string | 30m |
Analyze the most recent period of time, the format is: <n><m|h|d>, for example, 30m means the last 30 minutes. |
| --store_dir | No | string | Defaults to the current path where the command is executed | The local path where the results are stored. |
| --temp_dir | No | string | /tmp |
The temporary file storage directory generated by the remote node during the log collection process. |
| --files | No | string | Default is empty | --files is the offline analysis log file mode. Once --files is specified, it will enter the offline analysis log mode. You need to pass the OceanBase cluster log or log path. In the offline analysis mode, the --from, --to, --since settings will not need to be set, but you need to specify the OceanBase database version (--version) |
| --version | No | string | Default is empty | When specifying --files for offline analysis, the version of the OceanBase database needs to be passed. This parameter does not need to be passed during online analysis |
| -c | No | string | ~/.obdiag/config.yml |
Configuration file path. |
| --inner_config | No | string | Default is empty | obdiag's own configuration. |
| --config | No | string | Default is empty | Configuration of the cluster to be diagnosed by obdiag, fixed style: --config key1=value1 --config key2=value2.
ExplanationParameters that support configuration through this option can be found in obdiag configuration. |
| --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.
ExplanationFor details, please 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
--filesand--versionparameters are 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 memory --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
```* Quickly analyze the logs of the recent period:
```shell
# Online: analyze the last hour of logs pulled from remote hosts
obdiag analyze memory --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: memory analysis on the last hour of logs from remotes
# Provide sys tenant connection; obdiag resolves cluster node addresses
obdiag analyze memory --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: last 30 minutes memory analysis report
# Provide sys tenant connection; obdiag resolves cluster node addresses
obdiag analyze memory --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
$ obdiag analyze memory --files test/ --version 4.2.0.0
```* Offline analysis of specified observer logs:
```shell
obdiag analyze memory --files observer.log.20230831142211247 --version 4.2.2.0
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 memory --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
obdiag analyze memory --since 1h
# Online: analyze the last 30 minutes of logs pulled from remote hosts
obdiag analyze memory --since 30m
```* Offline analysis of specified observer logs:
```shell
# Offline: analyze the given log file(s)
obdiag analyze memory --files observer.log.20230831142211247
