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', primary_zone='zone1;zone2', resource_pool_list=('pool1');
where:
- 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.
For instructions on creating a tenant, see Create a tenant.
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...]) ;
Notes on using the statement:
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 background
Assume the cluster currently has only one zone named z1, which contains only one OBServer node. There is a user tenant named tenant1 in the cluster. Its current replica distribution is locality='F@z1', resource_pool_list=('pool1');. Due to business requirements, tenant tenant1 needs to be upgraded from single-replica to two-replica, that is, its locality changes from F@z1 to F@z1,F@z2.
Example operations
To accomplish this, perform the following steps:
The cluster currently has only one zone named
z1. You need to add zonez2to the cluster.For instructions on adding zones to a cluster, see Add a zone.
Add an OBServer node to
z2.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 zonez2.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=('z2');Then, add resources to
z2for the tenant.obclient>ALTER TENANT tenant1 RESOURCE_POOL_LIST =('pool1', 'pool2') ;
Increase the replicas by modifying the tenant's locality.
According to the locality modification rules, when the number of replicas of a tenant changes from 1 to 2, you can directly change the locality to
F@z1,F@z2. For more information about the locality modification rules, see Modify locality.obclient>ALTER TENANT tenant1 LOCALITY='F@z1,F@z2';