If OceanBase Diagnostic Tool (obdiag) is independently deployed, you can run the obdiag analyze memory command to analyze logs of an OceanBase cluster and generate a memory analysis report based on the memory usage information in the logs.
If your OceanBase cluster is deployed by using OceanBase Deployer (obd), you can run obdiag commands on obd to analyze the cluster. For more information about the commands, see obdiag commands.
Syntax
obdiag analyze memory [options]
You can run this command to analyze logs of an OceanBase cluster online and generate a memory analysis report based on the memory usage information in the logs. You can also 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 <n> <m|h|d> format, 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. |
| --store_dir | No | string | The current path where the command is executed | The local path where the results are stored. |
| --temp_dir | No | string | /tmp |
The directory where temporary files generated by the remote node during log collection are stored. |
| --files | No | string | Empty | Specifies to enable the offline log analysis mode. In offline analysis mode, you must specify the name or path of the log file of the OceanBase cluster as well as the OceanBase Database version (--version), but you do not need to specify the --from, --to, or --since option. |
| --version | No | string | Empty | The OceanBase Database version. This parameter is required only when --files is specified to enable the offline log analysis mode. |
| -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.
NoteFor information about the parameters supported by this option, see Configure obdiag. |
Note
- In online analysis mode, the runtime status of an OceanBase cluster is analyzed, and the logs are distributed on OBServer nodes of the cluster.
- In offline analysis mode, which is enabled by specifying the
--filesand--versionoptions, 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
Analyze logs online
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.xx.2 \ --config obcluster.servers.global.ssh_username=test \ --config obcluster.servers.global.ssh_password=****** \ --config obcluster.servers.global.home_path=/home/admin/oceanbaseQuickly analyze logs of a recent period
# Analyze the logs of the last hour online. When you run this command, obdiag pulls and analyzes the logs of the last hour 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.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 the logs of the last hour from remote hosts to analyze memory usage. # Specify the connection information of the sys tenant so that obdiag automatically obtains the IP addresses of all nodes in the cluster. 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 # Analyze the logs of the last 30 minutes online and generate a memory analysis report. # Specify the connection information of the sys tenant so that obdiag automatically obtains the IP addresses of all nodes in the cluster. 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/oceanbaseAnalyze logs offline
$ 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.0Analyze the specified
observer.logfile offlineobdiag analyze memory --files observer.log.20230831142211247 --version 4.2.2.0
Method 2: Use the command 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 file in the ~/.obdiag directory. For more information, see Configure obdiag.
Analyze logs online
obdiag analyze memory --from "2023-10-08 10:25:00" --to "2023-10-08 11:30:00"Quickly analyze logs of a recent period
# Analyze the logs of the last hour online. When you run this command, obdiag pulls and analyzes the logs of the last hour from remote hosts. obdiag analyze memory --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 remote hosts. obdiag analyze memory --since 30mAnalyze the specified
observer.logfile offline# Analyze a specified log file offline obdiag analyze memory --files observer.log.20230831142211247