After successfully creating a resource pool, you can allocate it to a tenant either during tenant creation or when modifying a tenant's resource pool list.
Scenario 1: Allocate a resource pool during tenant creation
When creating a tenant, you can allocate an unused resource pool to the tenant using the following SQL statement:
obclient> CREATE TENANT IF NOT EXISTS test_tenant charset='utf8mb4', replica_num=3, zone_list=('zone1','zone2','zone3'), primary_zone='zone1;zone2,zone3', resource_pool_list=('pool1');
For instructions on creating a tenant, see Create a tenant.
Note
A resource pool can be bound to only one tenant, but a tenant can have multiple resource pools.
The total amount of resources allocated to a tenant in a zone is determined by the resource unit configuration multiplied by the number of resource units.
Scenario 2: Allocate a resource pool when modifying a tenant's resource pool list
When modifying a tenant's resource pool list, you can allocate an unused resource pool to the tenant using the following SQL statement:
ALTER TENANT tenant_name RESOURCE_POOL_LIST [=](pool_name [, pool_name...]) ;Note
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 the same time.When adding a resource pool for a tenant, ensure that the zones used by the new resource pool differ from those used by the existing resource pools.
Modifying a tenant's resource pool list to add resource pools for the tenant is typically used in scenarios where the number of replicas for the tenant needs to be increased.
Example
Suppose there are three zones (
z1,z2,z3) in a cluster, all belonging to the same region, with one OBServer node in each zone. In this cluster, there is a user tenant namedtenant1with the current replica distributionlocality='F@z1,F@z2,F@z3', resource_pool_list=('pool1');. According to the business requirements, the number of replicas fortenant1needs to be increased from 3 to 5, that is, the locality of the tenant needs to be changed fromF@z1,F@z2,F@z3toF@z1,F@z2,F@z3,F@z4,F@z5.To accomplish this, perform the following steps:
Add two new 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.
For instructions on adding an OBServer node to a zone, see Add a node.
Log in to the
systenant using therootuser and add resources totenant1in zonesz4andz5.Before you add resources, make sure that resource units and resource pools are available.
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 to
z4andz5.obclient>ALTER TENANT tenant1 RESOURCE_POOL_LIST =('pool1', 'pool2') ;
Increase the replicas by modifying the tenant's locality.
According to the locality modification rules, you can add only one zone at the same time. For more information about the locality modification rules, see Modify locality.
obclient>ALTER TENANT tenant1 LOCALITY='F@z1,F@z2,F@z3,F@z4'; obclient>ALTER TENANT tenant1 LOCALITY='F@z1,F@z2,F@z3,F@z4,F@z5';