DEV Community

Qing
Qing

Posted on

Resource Management Preparation(1)

Planning Resources
Before configuring resource load management, plan tenant resources based on service models. After services run for a period of time, you can adjust the configurations based on resource usage.

Assume that two departments in a large enterprise use the same cluster. openGauss puts system resources used by the same department in a group to isolate resources for different departments. Table 1 describes the resource plan.

Table 1 Tenant resource plan

Image description

Enabling Resource Load Management
Background
This section describes how to configure parameters for resource load management.

Prerequisites
· In openGauss, you can manage system resources only as a database administrator. Run the following statement to query user permissions:

Image description

· Resource load management can be applied only to users with the login permission. Run the following statement to query user permissions:

Image description

Image description

Procedure
You can perform the following steps only as a database administrator to enable load management based on the resource pool. The following uses user omm as an example.

  1. Log in as the OS user omm to the primary node of openGauss.

  2. Enable resource pool–based load management.

Image description

  1. Restart the database for the parameter settings to take effect.

Image description

Setting a Cgroup
Background
The core of openGauss resource load management is resource pools. The first step of configuring a resource pool is to configure Cgroups in the environment. For details about Cgroup principles, see the product manual corresponding to your OS. For details about openGauss Cgroups, see Viewing Cgroup Information.

The Class Cgroup is a top-layer Cgroup for database service running. DefaultClass is a sub-category of the Class Cgroup and is automatically created when a cluster is deployed. The Medium Cgroup under DefaultClass contains running jobs that are triggered by the system. Resource configurations of Medium cannot be modified, and the jobs running on it are not controlled by resource management. Therefore, you are advised to create sub-Class and Workload Cgroups to control resource allocation.

Prerequisites
You are familiar with “Server Tools > gs_cgroup” and “Server Tools > gs_ssh” in Tool Reference.

Procedure

Image description

Creating sub-Class and Workload Cgroups

  1. Log in as the OS user omm to the primary node of openGauss.

  2. Create sub-Class Cgroups class_a and class_b, and allocate 40% and 20% of Class CPU resources to them, respectively.

Image description

  1. Create Workload Cgroups workload_a1 and workload_a2 under class_a, and allocate 20% and 60% of class_a CPU resources to them, respectively.

Image description

  1. Create Workload Cgroups workload_b1 and workload_b2 under class_b, and allocate 50% and 40% of class_b CPU resources to them, respectively.

Image description

Adjusting resource quotas for Cgroups

  1. Change the CPU resource quota for class_a to 30%.

Image description

  1. Change the CPU resource quota for workload_a1 under class_a to 30% of class_a CPU resources.

Image description

Image description

Deleting a Cgroup

  1. Delete the Cgroup class_a.

Image description

After the command is executed, the Cgroup class_a is deleted.

Image description

Viewing Cgroup Information

  1. View Cgroup information in configuration files.

Image description

Cgroup configuration

Image description

Table 1 lists the Cgroup configuration shown in the above example.

Table 1 Cgroup configuration

Image description

Image description

  1. View the Cgroup tree in the OS.

Run the following command to query the structure of the Cgroup tree:

Image description

In the command output, shares indicates the value of cpu.shares, which specifies the dynamic quota of CPU resources in the OS, and cpus indicates the value of cpuset.cpus, which specifies the dynamic quota of CPUSET resources in the OS (number of cores that a Cgroup can use).

Image description

  1. Obtain the Cgroup configuration in a system view.

3.1 Perform the steps in Using gsql to Connect to a Database.
3.2 Obtain the configuration about all Cgroups in the system.

Image description

Top comments (0)