DBMind Mode-service
Tags: opengauss
Published: 2023-04-11 04:51:52

This subcommand can be used to initialize the configuration directory and start and stop background tasks.

**Initializing the Configuration Directory**

You can run the **gs_dbmind** service setup subcommand to initialize the configuration directory. This directory may contain the configuration files and logs of the DBMind. Some files in the directory are described as follows:

**·** **dbmind.conf**: DBMind parameter configuration file. You can modify it using the **gs_dbmind** set command or a text editor.

**·** **dynamic_config.db**: DBMind service metadata stored on the local node, including algorithm hyperparameters and monitoring thresholds. This file contains DBMind service metadata and cannot be configured by users.

**·** **metric_map.conf**: monitoring metric mapping table, which can be used to adapt to different collection platforms. For example, in DBMind, the monitored system CPU usage is named **os_cpu_usage**, but a user-defined collection tool may name the CPU usage **my_cpu_usage_rate**. In this case, if you want DBMind to represent the CPU usage metric **my_cpu_usage_rate**, you need to modify this configuration item. That is, add the **os_cpu_usage** = **my_cpu_usage_rate** configuration item for mapping. For common users, you are advised to use the collection component and solution of the DBMind. In this case, you do not need to modify the configuration file.

**·** **logs**: This directory stores logs generated by the DBMind service.

You can initialize the configuration directory in interactive or non-interactive mode. For example, if the name of the configuration directory to be initialized is confpath, perform the following operations:

**Interactive mode**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/00d7gpirxwqxl315t7ta.png)

After running the preceding command, you can configure the configuration items in interactive mode through the CLI client.

**Non-interactive mode**

In non-interactive mode, the initialization consists of three steps: starting configuration, modifying configuration items, and initializing configuration. In the second step, you need to manually edit the configuration file by using the text editor. The procedure is as follows:

1. Run the following command to start the configuration:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vj94z25yhznsrdv7xcjl.png)

2. After manually modifying the preceding parameters, initialize the configuration items. In this phase, DBMind preliminarily checks the correctness of configuration items, initializes the structure and content of the metadata database table for storing result data, and encrypts the plaintext passwords in the configuration items.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sl6r7q1qeie38m7000q4.png)

3. Start the DBMind background service based on the configuration directory.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cnldhgdsl2k92eftwyst.png)

**Starting a Service**
After the configuration directory is initialized, you can start the DBMind background service based on the configuration directory. For example, if the configuration directory is **confpath**, run the following command:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ohk9v6nlwuxkbpy8jbty.png)

After the preceding command is executed, the system displays a message indicating that the service has been started. If no additional parameter is specified, this command starts all background tasks by default. If you want to start only one background task, add the **–only-run** option. For example, if you only want to start the slow SQL root cause analysis service, run the following command:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dzxjv5r0fxz0eun7ske6.png)

**Stopping a Service**
Similar to starting a service, stopping a service has a simpler command line structure. You only need to specify the address of the configuration directory. For example, if the configuration directory is **confpath**, run the following command:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6x4mp7rkchnzsz56t26z.png)

The DBMind service automatically exits after the running task is complete in the background.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0wc8lkj87idqz1hcvmf3.png)

**Command Reference**
You can use the –help option to obtain the help information about this mode. For example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x262xb1g9p2u8zxgswfu.png)

Table 1 Parameters of the gs_dbmind service subcommand

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i4004fzt218y59n5g2a6.png)