This article applies to the scenario of independently deploying obdiag. Using the obdiag gather command can help collect diagnostic information related to the OceanBase database. The scenes gather command can be executed with one click to retrieve the troubleshooting information required for certain problem scenarios, solving the pain point of difficulty in obtaining distributed node information.
Prerequisites
You need to ensure that the login information of the node to be collected has been configured in the obdiag configuration file config.yml. For related detailed configuration introduction, see obdiag configuration.
View currently supported scenarios
obdiag gather scene list
obdiag gather scene run use
obdiag gather scene run --scene={SceneName}
The options are explained below:
Option name |
Is it required |
Data type |
Default value |
Description |
|---|---|---|---|---|
| --scene | Yes | string | Default is empty | Scene name, you can use obdiag gather scene list to see which scenes the current version supports |
| --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 |
Log collection for a recent period of time, the format is: <n><m|h|d>, for example, 30m means collecting logs for the last 30 minutes. |
| --env | No | string | Default is empty | Some scenarios require additional parameters to support, which can be set through --env, format: --env key=value, which can be specified multiple times. For example: --env host=127.0.0.1 --env port=2881 --env user=test@test --env password=****** --env database=test. For specific configuration methods, please refer to the corresponding scenario introduction document. |
| --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 collection process. |
| --skip_type | No | string | Default is empty | The collection type to be skipped, configurable values are ssh, sql. Use commas (,) to separate multiple values. |
| --redact | No | string | Default is empty | Select the OceanBase cluster log desensitization rule. For example, it can be configured as all_sql. When using multiple rules, use English commas (,) to separate them. To write the rules, refer to the introduction of this article [Preparing desensitization rules] (../100.normal/101.gather_log.md). |
| -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 | Configuration of the cluster to be diagnosed by obdiag, fixed style: --config key1=value1 --config key2=value2.
ExplanationThe parameters 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. For details, see Configuration File Encryption. |
Description
If the storage directory store_dir is not specified, the collected results will be stored in the gather_pack_xxxx folder in the current directory
Usage example
Method 1: Use without configuration file (out of the box)
obdiag gather scene run --scene={SceneName} \
--config db_host=xx.xx.xx.xx \
--config db_port=xxxx \
--config tenant_sys.user=root@sys \
--config tenant_sys.password=*** \
--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.ssh_username=test \
--config obcluster.servers.global.ssh_password=****** \
--config obcluster.servers.global.home_path=/home/admin/oceanbase \
--config obproxy.servers.nodes[0].ip=xx.xx.xx.3 \
--config obproxy.servers.nodes[1].ip=xx.xx.xx.4 \
--config obproxy.servers.global.ssh_username=test \
--config obproxy.servers.global.ssh_password=****** \
--config obproxy.servers.global.home_path=/home/admin/obproxy
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 config.yml. For related detailed configuration introduction, see obdiag configuration.
obdiag gather scene run --scene={SceneName}
Custom scene writing tutorial
A task represents an independent scenario, which can be understood as a professional script file written in yaml and recognized by obdiag.
Before starting to write
Before writing, you need to determine where the yaml needs to be placed.
You can first enter the directory identified by gather.scenes_base_path in the /opt/oceanbase-diagnostic-tool/conf/inner_config.yml file to see if the collection scene you wrote belongs to an existing category. If not, create a folder to declare this category.
Example:```
ssh script
cd ~/.obdiag/gather/tasks/observer touch test.yaml
The above completes the steps before writing
### Start writing
To start writing, start editing our test.yaml
```yaml
# Describe what this scenario does (human-readable summary)
info: "for test"
Simple content is over, complex writing begins, pay attention to details
Scene writing
The function of task is to declare the steps for scene collection execution. In order to be compatible with the differences in steps that may occur in different versions, its basic structure is a list.
The structure of an element of task is as follows
Parameter name |
Is it required |
Description |
Data type |
|---|---|---|---|
| version | No | Indicates the applicable version, see the following example for usage | Use the form of str to express the range, which requires a complete digital version number. The 3. |
| steps | Yes | The steps executed | are list structures |
The following is an example
info: testinfo
task:
- version: "[3.1.0,3.2.4]"
steps:
{steps_object}
- version: [4.2.0.0,4.3.0.0]
steps:
{steps_object}
steps is also a list, used to represent multiple specific execution processes.
The structure of an element of steps is a single process, as follows
Parameter name |
Is it required |
Description |
|---|---|---|
| type | Yes | indicates the applicable execution type. Currently, ssh/sql/log/obproxy_log/sysstat is supported, and supported types will continue to be added in the future |
| {ssh/sql/log/obproxy_log/sysstat} | Yes | Based on the parameters provided by the selected type, this section relies more on the logical description of the execution type in the code. This chapter will provide detailed instructions for the supported execution types later in this chapter |
Examples of various types are as follows. "step:" is just a mark and has no actual effect.
ssh
Execute instructions remotely and obtain the corresponding return value
step:
type: ssh
ssh: wc -l /proc/${task_OBServer_pid}/maps | awk '{print $1}'
global: false # Per-node: true runs once on first node only; false runs on every node
sql
Execute sql and get the corresponding value
step:
type: sql
sql: select tenant_name from oceanbase.__all_tenant;
global: false
log
Collect logs from OceanBase database
step:
type: log
grep: "" # Filter pattern
global: false
obproxy_log
Collect OBProxy logs
step:
type: obproxy_log
grep: "" # Filter pattern
global: false
sysstat
Collect host information
step:
type: sysstat
sysstat: ""
global: false
```<main id="notice" type='explain'>
<h4>Description</h4>
<p> The global field is relative to the node. When it is marked true, it will only be executed once when the first node is executed. If it is marked false, it will be executed on each node</p>
</main>