After resource pools are created successfully, you can allocate a resource pool to a tenant during tenant creation or when modifying the resource pool list by assigning an unused resource pool to the tenant.
Allocate a resource pool during tenant creation
When creating a tenant, you can allocate an unused resource pool to the tenant. Example:
obclient> CREATE TENANT IF NOT EXISTS test_tenant charset='utf8mb4', primary_zone='zone1;zone2,zone3', resource_pool_list=('pool1');
The following rules apply:
- A resource pool can be bound to only one tenant. A tenant can have multiple resource pools.
- The total amount of resources allocated to a tenant in a Zone equals the Unit specification multiplied by the number of Units.
For more information about creating a tenant, see Create a tenant.
Allocate a resource pool when modifying a tenant's resource pool list
You can also allocate an unused resource pool to a tenant by using the ALTER TENANT statement when modifying the tenant's resource pool list. Example:
ALTER TENANT tenant_name RESOURCE_POOL_LIST [=](pool_name [, pool_name...]) ;
Note the following:
This statement can only be executed by the administrator of the
systenant.For
RESOURCE_POOL_LIST, only one resource pool can be added or deleted at a time.When adding a resource pool for a tenant, the Zones used by the resource pool to be added must not overlap with those used by the existing resource pools.
Modifying a tenant's resource pool list to add resource pools is typically used when upgrading the number of tenant replicas.
Example background
Suppose the cluster currently has only three zones (z1, z2, and z3), all belonging to the same Region, with one OBServer node in each zone. The cluster has a user tenant tenant1 with the current replica distribution locality='F@z1,F@z2,F@z3', resource_pool_list=('pool1');. According to business requirements, the number of replicas for tenant1 needs to be increased from 3 to 5, that is, the tenant's locality needs to be changed from F@z1,F@z2,F@z3 to F@z1,F@z2,F@z3,F@z4,F@z5.
Example procedure
The cluster currently has only three zones (
z1,z2, andz3). Add two zones (z4andz5) to the cluster.For instructions on adding zones to a cluster, see Add a zone.
Add one OBServer node to each of the new zones (
z4andz5).For instructions on adding OBServer nodes to a zone, see Add a node.
Log in to the
systenant as therootuser and add resources fortenant1inz4andz5.Create resource units and resource pools before adding resources.
obclient>CREATE RESOURCE UNIT unit2 MAX_CPU 1, MIN_CPU 1, MEMORY_SIZE '5G', MAX_IOPS 1024, MIN_IOPS 1024, IOPS_WEIGHT 0,LOG_DISK_SIZE '2G'; obclient>CREATE RESOURCE POOL pool2 unit = 'unit2', unit_num = 1, zone_list=('z4','z5');Add resources for the tenant in
z4andz5.obclient>ALTER TENANT tenant1 RESOURCE_POOL_LIST =('pool1', 'pool2') ;
Increase the number of replicas by modifying the tenant's locality.
According to the locality modification rules, when changing a tenant from 3 replicas to 5 replicas, you can directly change the locality to
F@z1,F@z2,F@z3,F@z4,F@z5. For more information about the locality modification rules, see Modify locality.obclient>ALTER TENANT tenant1 LOCALITY='F@z1,F@z2,F@z3,F@z4,F@z5';