CREATE RESOURCE GROUPgroup_nameTYPE = {SYSTEM|USER} [VCPU [=]vcpu_spec[,vcpu_spec] ...] [THREAD_PRIORITY [=]N] [ENABLE|DISABLE]vcpu_spec: {N|M-N}
CREATE RESOURCE GROUP is used for resource group management (see Section 5.1.16, “Resource Groups”). 用于资源组管理(请参阅第5.1.16节,“资源组”)。This statement creates a new resource group and assigns its initial attribute values. 此语句创建一个新的资源组并分配其初始属性值。It requires the 它需要RESOURCE_GROUP_ADMIN privilege.RESOURCE_GROUP_ADMIN权限。
group_name identifies which resource group to create. group_name标识要创建的资源组。If the group already exists, an error occurs.如果该组已存在,则会发生错误。
The TYPE attribute is required. TYPE属性是必需的。It should be 它应该是系统资源组的SYSTEM for a system resource group, USER for a user resource group. SYSTEM,用户资源组的USER。The group type affects permitted 如下文所述,组类型会影响允许的THREAD_PRIORITY values, as described later.THREAD_PRIORITY值。
The VCPU attribute indicates the CPU affinity; that is, the set of virtual CPUs the group can use:VCPU属性表示CPU相关性;也就是说,该组可以使用的虚拟CPU集:
If 如果未提供VCPU is not given, the resource group has no CPU affinity and can use all available CPUs.VCPU,则资源组没有CPU关联,可以使用所有可用的CPU。
If 如果给定了VCPU is given, the attribute value is a list of comma-separated CPU numbers or ranges:VCPU,则属性值为逗号分隔的CPU编号或范围列表:
Each number must be an integer in the range from 0 to the number of CPUs − 1. For example, on a system with 64 CPUs, the number can range from 0 to 63.每个数字必须是一个介于0到CPU数量1之间的整数。例如,在一个有64个CPU的系统上,这个数字可以在0到63之间。
A range is given in the form 范围以M − N, where M is less than or equal to N and both numbers are in the CPU range.M-N的形式给出,其中M小于或等于N,两个数字都在CPU范围内。
If a CPU number is an integer outside the permitted range or is not an integer, an error occurs.如果CPU号是超出允许范围的整数或不是整数,则会发生错误。
Example VCPU specifiers (these are all equivalent):VCPU说明符示例(这些都是等效的):
VCPU = 0,1,2,3,9,10 VCPU = 0-3,9-10 VCPU = 9,10,0-3 VCPU = 0,10,1,9,3,2
The THREAD_PRIORITY attribute indicates the priority for threads assigned to the group:THREAD_PRIORITY属性表示分配给组的线程的优先级:
If 如果未指定THREAD_PRIORITY is not given, the default priority is 0.THREAD_PRIORITY,则默认优先级为0。
If 如果给定了THREAD_PRIORITY is given, the attribute value must be in the range from -20 (highest priority) to 19 (lowest priority). THREAD_PRIORITY,则属性值必须在-20(最高优先级)到19(最低优先级)之间。The priority for system resource groups must be in the range from -20 to 0. 系统资源组的优先级必须在-20到0之间。The priority for user resource groups must be in the range from 0 to 19. 用户资源组的优先级必须在0到19之间。Use of different ranges for system and user groups ensures that user threads never have a higher priority than system threads.对系统和用户组使用不同的范围可以确保用户线程的优先级永远不会高于系统线程。
ENABLE and DISABLE specify that the resource group is initially enabled or disabled. ENABLE和DISABLE指定资源组最初处于启用或禁用状态。If neither is specified, the group is enabled by default. 如果两者都未指定,则默认情况下该组处于启用状态。A disabled group cannot have threads assigned to it.禁用的组不能分配线程。
Examples:
Create an enabled user group that has a single CPU and the lowest priority:创建具有单个CPU和最低优先级的已启用用户组:
CREATE RESOURCE GROUP rg1 TYPE = USER VCPU = 0 THREAD_PRIORITY = 19;
Create a disabled system group that has no CPU affinity (can use all CPUs) and the highest priority:创建一个没有CPU关联(可以使用所有CPU)且优先级最高的禁用系统组:
CREATE RESOURCE GROUP rg2 TYPE = SYSTEM THREAD_PRIORITY = -20 DISABLE;
Resource group management is local to the server on which it occurs. 资源组管理是发生在其上的服务器的本地管理。CREATE RESOURCE GROUP statements are not written to the binary log and are not replicated.CREATE RESOURCE GROUP语句不会写入二进制日志,也不会被复制。