当前位置:网站首页>Database resource load management (Part 2)
Database resource load management (Part 2)
2022-06-11 15:48:00 【Gauss squirrel Club】
Set up control group
Background information
openGauss The core of resource load management is resource pool , To configure the resource pool, we must first implement the control group in the environment Cgroups Set up . more Cgroups Introduction to the principle of , Please check the product manual of the relevant operating system .
Class The control group is the top-level control group where the database business runs , When the cluster is deployed, the default child will be automatically generated Class Control group “DefaultClass”.DefaultClass Of Medium The control group will contain system triggered jobs running , This control group does not allow resource modification , And the jobs running on the control group are not controlled by resource management , Therefore, it is recommended to create a new sub Class And its Workload Control group to set the resource proportion .
Prerequisite
Already familiar 《 Tool reference 》 in “ Server tools > gs_cgroup” Chapters and “ Server tools > gs_ssh” Use of chapters .
Operation steps
explain :
- stay openGauss in , The creation of the control group needs to be performed on each cluster node 、 to update 、 Delete operation , In order to control the resources of the whole cluster , So... Is used in the following steps 《 Tool reference 》 in “ Server tools > gs_ssh” Command execution .
- The naming requirements of the control group are as follows :
- Whether it's a son Class The control group is still Workload Control group , It is not allowed to include characters in the name “:”.
- You cannot create a control group with the same name .
Create a child Class Control group and Workload Control group
1、 Operating system users omm Sign in openGauss Master node .
2、 Create name as “class_a” and “class_b” The son of Class Control group ,CPU The resource quotas are Class Of 40% and 20%.
gs_ssh -c "gs_cgroup -c -S class_a -s 40"
gs_ssh -c "gs_cgroup -c -S class_b -s 20"
3、 Create a child Class Control group “class_a” The following name is “workload_a1” and “workload_a2” Of Workload Control group ,CPU The resource quotas are “class_a” Control group 20% and 60%.
gs_ssh -c "gs_cgroup -c -S class_a -G workload_a1 -g 20 "
gs_ssh -c "gs_cgroup -c -S class_a -G workload_a2 -g 60 "
4、 Create a child Class Control group “class_b” The following name is “workload_b1” and “workload_b2” Of Workload Control group ,CPU The resource quotas are “class_b” Control group 50% and 40%.
gs_ssh -c "gs_cgroup -c -S class_b -G workload_b1 -g 50 "
gs_ssh -c "gs_cgroup -c -S class_b -G workload_b2 -g 40 "
Update the resource quota of the control group
1、 to update “class_a” Control group CPU The resource quota is 30%.
gs_ssh -c "gs_cgroup -u -S class_a -s 30"
2、 to update “class_a” Under the “workload_a1” Of CPU The resource quota is “class_a” Of 30%.
gs_ssh -c "gs_cgroup -u -S class_a -G workload_a1 -g 30"
instructions : Adjusted Workload Control group “workload_a1” In possession of CPU The resource should not be greater than its corresponding child Class Control group “class_a”. also , This name cannot be Timeshare Cgroup The default name of , Such as “Low”、“Medium”、“High” or “Rush”.
Delete control group
gs_ssh -c "gs_cgroup -d -S class_a"
The above operation can delete the control group “class_a”.
instructions : root The user may have root The user with access rights specifies “-d” and “-U username” Delete normal users “username” Accessible default Cgroups. Ordinary users specify “-d” and “-S classname” You can delete existing Class Cgroups.
View the information of the control group
1、 View the control group information in the configuration file .
gs_cgroup -p
Control group configuration information
gs_cgroup -p
Top Group information is listed:
GID: 0 Type: Top Percent(%): 1000( 50) Name: Root Cores: 0-47
GID: 1 Type: Top Percent(%): 833( 83) Name: Gaussdb:omm Cores: 0-20
GID: 2 Type: Top Percent(%): 333( 40) Name: Backend Cores: 0-20
GID: 3 Type: Top Percent(%): 499( 60) Name: Class Cores: 0-20
Backend Group information is listed:
GID: 4 Type: BAKWD Name: DefaultBackend TopGID: 2 Percent(%): 266(80) Cores: 0-20
GID: 5 Type: BAKWD Name: Vacuum TopGID: 2 Percent(%): 66(20) Cores: 0-20
Class Group information is listed:
GID: 20 Type: CLASS Name: DefaultClass TopGID: 3 Percent(%): 166(20) MaxLevel: 1 RemPCT: 100 Cores: 0-20
GID: 21 Type: CLASS Name: class1 TopGID: 3 Percent(%): 332(40) MaxLevel: 2 RemPCT: 70 Cores: 0-20
Workload Group information is listed:
GID: 86 Type: DEFWD Name: grp1:2 ClsGID: 21 Percent(%): 99(30) WDLevel: 2 Quota(%): 30 Cores: 0-5
Timeshare Group information is listed:
GID: 724 Type: TSWD Name: Low Rate: 1
GID: 725 Type: TSWD Name: Medium Rate: 2
GID: 726 Type: TSWD Name: High Rate: 4
GID: 727 Type: TSWD Name: Rush Rate: 8
Group Exception information is listed:
GID: 20 Type: EXCEPTION Class: DefaultClass
PENALTY: QualificationTime=1800 CPUSkewPercent=30
GID: 21 Type: EXCEPTION Class: class1
PENALTY: AllCpuTime=100 QualificationTime=2400 CPUSkewPercent=90
GID: 86 Type: EXCEPTION Group: class1:grp1:2
ABORT: BlockTime=1200 ElapsedTime=2400
The control group configuration information viewed in the above example is shown in table 1 Shown .
surface 1 Control group configuration information 
2、 View the control group information of the tree structure in the operating system .
Execute the following command to query the control group tree structure information .
gs_cgroup -P
The return message is as follows , among shares Represents... In the operating system CPU Dynamic resource quotas for resources “cpu.shares” The numerical ,cpus Represents... In the operating system CPUSET Dynamic resource limits for resources “cpuset.cpus” The numerical , It refers to the audit range that the control group can use .
Mount Information:
cpu:/dev/cgroup/cpu
blkio:/dev/cgroup/blkio
cpuset:/dev/cgroup/cpuset
cpuacct:/dev/cgroup/cpuacct
Group Tree Information:
- Gaussdb:wangrui (shares: 5120, cpus: 0-20, weight: 1000)
- Backend (shares: 4096, cpus: 0-20, weight: 400)
- Vacuum (shares: 2048, cpus: 0-20, weight: 200)
- DefaultBackend (shares: 8192, cpus: 0-20, weight: 800)
- Class (shares: 6144, cpus: 0-20, weight: 600)
- class1 (shares: 4096, cpus: 0-20, weight: 400)
- RemainWD:1 (shares: 1000, cpus: 0-20, weight: 100)
- RemainWD:2 (shares: 7000, cpus: 0-20, weight: 700)
- Timeshare (shares: 1024, cpus: 0-20, weight: 500)
- Rush (shares: 8192, cpus: 0-20, weight: 800)
- High (shares: 4096, cpus: 0-20, weight: 400)
- Medium (shares: 2048, cpus: 0-20, weight: 200)
- Low (shares: 1024, cpus: 0-20, weight: 100)
- grp1:2 (shares: 3000, cpus: 0-5, weight: 300)
- TopWD:1 (shares: 9000, cpus: 0-20, weight: 900)
- DefaultClass (shares: 2048, cpus: 0-20, weight: 200)
- RemainWD:1 (shares: 1000, cpus: 0-20, weight: 100)
- Timeshare (shares: 1024, cpus: 0-20, weight: 500)
- Rush (shares: 8192, cpus: 0-20, weight: 800)
- High (shares: 4096, cpus: 0-20, weight: 400)
- Medium (shares: 2048, cpus: 0-20, weight: 200)
- Low (shares: 1024, cpus: 0-20, weight: 100)
- TopWD:1 (shares: 9000, cpus: 0-20, weight: 900)
3、 Obtain the control group configuration information through the system view .
a. Use gsql Connect to database .
b. Get the configuration information of all control groups in the system .
openGauss=# SELECT * FROM gs_all_control_group_info;
Create resource pools
Background information
openGauss Support the division of host resources by creating a resource pool . After starting resource load management , Only using the default resource pool can not meet the demands of business for resource load management , You must create new resource pools as needed , Reallocate system resources , To meet the needs of the actual business for the fine management of system resources . The characteristics of common resource pool are shown in table 1.
surface 1 Characteristics of common resource pool
| Resource pool classification | characteristic |
|---|---|
| Common resource pool ( Ordinary scenes ) | 1、 relation Workload Control group . And there must be no group resource pool associated with the corresponding child of the control group class. That is, if you create a business resource pool association control group ‘class1:wd’, Then there must be no group resource pool Association ‘class1’.2、mem_percent The default is 0%, No, mem_percent Additive less than 100% The limitation of . |
After the resource load management function is enabled , Automatically created default_pool, When a session or user does not specify an associated resource pool , Will be linked to by default default_pool.default_pool The default binding DefaultClass:Medium Control group , And there is no limit to the number of concurrent transactions associated with it .default_pool The detailed properties of are shown in table 2 Shown .
surface 2 default_pool attribute
| attribute | Property value | explain |
|---|---|---|
| respool_name | default_pool | Resource pool name . |
| mem_percent | 100 | Maximum percentage of memory used . |
| cpu_affinity | -1 | CPU Affinity , Reserved parameters . |
| control_group | DefaultClass:Medium | The control group associated with the resource pool . |
| active_statements | -1 | The maximum number of concurrencies allowed by the resource pool .-1 To not limit the number of concurrent . |
| max_dop | 1 | Turn on SMP after , Concurrency of operator execution , Reserved parameters . |
| memory_limit | 8GB | Maximum memory usage , Reserved parameters . |
| parentid | 0 | Parent resource pool OID. |
| io_limits | 0 | Trigger per second IO The maximum number of times . The unit of bank deposit is ten thousand times /s, It's time to save /s.0 Does not control . |
| io_priority | None | IO Utilization is as high as 90% when , Heavy consumption IO The homework goes on IO The priority level associated with resource control .None Does not control . |
| nodegroup | installation | The name of the logical cluster where the resource pool is located . |
| is_foreign | f | The resource pool is not used for users outside the logical cluster . |
instructions : openGauss Don't allow to default_pool Parameter modification .
Prerequisite
Already familiar CREATE RESOURCE POOL、ALTER RESOURCE POOL and DROP RESOURCE POOL The use of grammar .
The operation process
Create resource pools
1、 Use gsql Connect to database .
2、 Create a group resource pool and associate it to the specified child Class Control group . For example, the following : The name is “resource_pool_a” Group resource pool associated with “class_a” Control group .
openGauss=# CREATE RESOURCE POOL resource_pool_a WITH (control_group='class_a');
openGauss=# CREATE RESOURCE POOL resource_pool_b WITH (control_group='class_b');
CREATE RESOURCE POOL
3、 Create a business resource pool to associate with the specified resource pool Workload Control group . For example, the following : The name is “resource_pool_a1” The business resource pool of is associated with “workload_a1” Control group .
openGauss=# CREATE RESOURCE POOL resource_pool_a1 WITH (control_group='class_a:workload_a1');
openGauss=# CREATE RESOURCE POOL resource_pool_a2 WITH (control_group='class_a:workload_a2');
openGauss=# CREATE RESOURCE POOL resource_pool_b1 WITH (control_group='class_b:workload_b1');
openGauss=# CREATE RESOURCE POOL resource_pool_b2 WITH (control_group='class_b:workload_b2');
CREATE RESOURCE POOL
explain :
- If the associated control group is not specified when creating the resource pool , The resource pool will be associated with the default control group (DefaultClass Under the control group “Medium” Timeshare Control group ).
- control_group Values are case sensitive , Use single quotation marks when specifying .
- If the database user specifies Timeshare The string represented by the control group , namely “Rush”、“High”、“Medium” or “Low” One of them , Such as control_group The string of is “High”, Indicates that the resource pool is assigned to DefaultClass Under the control group “High” Timeshare Control group .
- control_group Users can create Workload Control group , namely ’class1:wd’, You can also have levels with control groups , for example :‘class1:wd:2’, The range of this level must be 1-10 Within the scope of , But this level will not make any distinction . In the old version , Allow to create a file with the same name Workload Control group , Distinguish by level . But after the new version is upgraded , It is not allowed to create a control group with the same name , If the user has created the same name in the old version Workload Control group , The level will not be distinguished during use , This may cause the problem of unclear use of the control group , The user needs to delete the old control group with the same name to specify the use of the control group .
Manage resource pools
Modify the properties of the resource pool . For example, the following : Modify resource pool “resource_pool_a2” The associated control group is “class_a:workload_a1”( hypothesis class_a:workload_a1 Not associated with another resource pool ).
openGauss=# ALTER RESOURCE POOL resource_pool_a2 WITH (control_group="class_a:workload_a1");
ALTER RESOURCE POOL
Delete resource pool
Delete resource pool . For example, delete the resource pool “resource_pool_a2”.
openGauss=# DROP RESOURCE POOL resource_pool_a2;
DROP RESOURCE POOL
explain :
- If a role is already associated with the resource pool , Cannot delete .
- Multi tenant scenario , If you delete a group resource pool , Its business resource pool will be deleted . Only when there is no associated user , Resource pool can be deleted .
View resource pool information
instructions :
1、 Not allowed INSERT、UPDATE、DELETE、TRUNCATE System table for operating resource load management pg_resource_pool.
2、 Modification of resource pool is not allowed memory_limit and cpu_affinity attribute .
- View all resource pool information in the current cluster .
openGauss=# SELECT * FROM PG_RESOURCE_POOL;
respool_name | mem_percent | cpu_affinity | control_group | active_statements | max_dop | memory_limit | parentid | io_limits | io_priority | nodegroup | is_foreign | max_worker
------------------+-------------+--------------+---------------------+-------------------+---------+--------------+----------+-----------+--------------+--------------+------------
default_pool | 100 | -1 | DefaultClass:Medium | -1 | 1 | 8GB | 0 | 0 | None | installation | f |
resource_pool_a | 20 | -1 | class_a | 10 | 1 | 8GB | 0 | 0 | None | installation | f |
resource_pool_b | 20 | -1 | class_b | 10 | 1 | 8GB | 0 | 0 | None | installation | f |
resource_pool_a1 | 20 | -1 | class_a:workload_a1 | 10 | 1 | 8GB | 16970 | 0 | None | installation | f |
resource_pool_a2 | 20 | -1 | class_a:workload_a2 | 10 | 1 | 8GB | 16970 | 0 | None | installation | f |
resource_pool_b1 | 20 | -1 | class_b:workload_b1 | 10 | 1 | 8GB | 16971 | 0 | None | installation | f |
resource_pool_b2 | 20 | -1 | class_b:workload_b2 | 10 | 1 | 8GB | 16971 | 0 | None | installation | f |
(7 rows)
- View the control group information associated with a resource pool , For details, please refer to... In the chapter of statistical information function gs_control_group_info(pool text) function .
In the following command “resource_pool_a1” Name the resource pool .
openGauss=# SELECT * FROM gs_control_group_info('resource_pool_a1');
name | class | workload | type | gid | shares | limits | rate | cpucores
---------------------+---------+-------------+-------+-----+--------+--------+------+----------
class_a:workload_a1 | class_a | workload_a1 | DEFWD | 87 | 30 | 0 | 0 | 0-3
(1 row)
surface 3 gs_control_group_info attribute
| attribute | Property value | explain |
|---|---|---|
| name | class_a:workload_a1 | class and workload name |
| class | class_a | Class Control group name |
| workload | workload_a1 | Workload Control group name |
| type | DEFWD | Control group type (Top、CLASS、BAKWD、DEFWD、TSWD) |
| gid | 87 | Control group id |
| shares | 30 | Account for the parent node CPU % of resources |
| limits | 0 | Account for the parent node CPU Percentage of audit |
| rate | 0 | Timeshare Distribution proportion in |
| cpucores | 0-3 | CPU The core number |
边栏推荐
- 数据库密态等值查询概述及操作
- openGauss简单查询SQL的执行流程解析
- Shutter-- page Jump animation
- Kaixia takes the lead in launching a new generation of UFS embedded flash memory devices that support Mipi m-phy v5.0
- Daily blog - wechat service permission 12 matters
- YEF 2022昨日开幕,多网络平台全程免费直播,开启在线技术盛宴!
- GO語言-值類型和引用類型
- 带你深度了解AGC云数据库
- 【创建型模式】单例模式
- ASEMI的MOS管24N50参数,24N50封装,24N50尺寸
猜你喜欢
随机推荐
Intercept string (function)
Unified record of my code variable names
Easy to use GS_ Dump and GS_ Dumpall command export data
微软韦青:狗尾巴的故事—数智时代的第一性原理 | 极客时间
知网被立案调查;字节跳动成立抖音集团,或在港上市;钉钉被曝裁员30%;北京人均存款超20万元 |Q资讯
关于 JS 函数的一切
[creation mode] single instance mode
openGauss数据库JDBC环境连接配置(Eclipse)
我的代码变量名称统一 记录
MAUI 入门教程系列(1.框架简介)
零基础自学软件测试,我花7天时间整理了一套学习路线,希望能帮助到大家..
码农必备SQL调优(下)
使用Cloud DB构建APP 快速入门-Server篇
[0006] titre, mots clés et description de la page
YEF 2022昨日开幕,多网络平台全程免费直播,开启在线技术盛宴!
Using cloud DB to build apps quick start - quick games
GO语言-值类型和引用类型
[azure application service] nodejs express + msal realizes the authentication experiment of API Application token authentication (AAD oauth2 idtoken) -- passport authenticate('oauth-bearer', {session:
向数据库导入数据?试试COPY FROM STDIN语句
With a lamp inserted in the nostril, the IQ has risen and become popular in Silicon Valley. 30000 yuan is enough
![[creation mode] prototype mode](/img/2b/5e6f4f9ca0718221ee1383243b794f.png)


![[daily question series]: how to test web forms?](/img/80/d0862275b547a7b5224d1c0effa779.jpg)





