After a resource pool is created, you can allocate it to a tenant when you create the tenant. You can also allocate an unused resource pool to a tenant when you modify the resource pool list of the tenant.
Allocate a resource pool when you create a tenant
When you create a tenant, you can allocate an unused resource pool to the tenant. The sample statement is as follows:
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')
Some notes about this:
You can bind a resource pool only to one tenant, while a tenant can have multiple resource pools. However, when you create a tenant, you can specify only one resource pool for the tenant.
The total amount of resources allocated to a tenant in a zone is calculated as follows: Unit configs × Unit quantity.
For more information about how to create a tenant, see Create a tenant.
Allocate a resource pool when you modify the resource pool list of a tenant
You can execute the ALTER TENANT statement to allocate an unused resource pool to a tenant:
ALTER TENANT tenant_name RESOURCE_POOL_LIST [=](pool_name [, pool_name...]) ;
Some notes about this:
This statement can be executed only by the administrator of the
systenant.This statement can add or delete only one resource pool specified by
RESOURCE_POOL_LISTat a time.When you add a resource pool for a tenant, the zone to which the resource pool belongs must be different from the zones to which the existing resource pools belong.
Usually, you can modify the resource pool list of a tenant to add resource pools for the tenant when the number of replicas of the tenant needs to be increased.
Sample scenario
Assume that the current cluster has three zones, which are z1, z2, and z3. The three zones belong to the same region, and each zone has one OBServer node. tenant1 in the cluster is a user tenant. Replica distribution of the tenant is as follows: locality='F@z1,F@z2,F@z3', resource_pool_list=('pool1');. Based on business needs, the number of replicas of tenant1 must be increased from 3 to 5. That is, the locality of the tenant must be changed from F@z1,F@z2,F@z3 to F@z1,F@z2,F@z3,F@z4,F@z5.
Sample procedure
Add zones
z4andz5to the cluster.For more information about how to add zones in a cluster, see Add or delete a zone.
Add an OBServer node to each of
z4andz5.For more information about how to add an OBServer node to a zone, see Add an OBServer node.
Log on to the
systenant as therootuser, and add resources for tenanttenant1in zonesz4andz5.Before you add resources, make sure that resource units and resource pools are available.
obclient> CREATE RESOURCE UNIT unit2 MAX_CPU 1, MAX_MEMORY '5G', MAX_IOPS 128,MAX_DISK_SIZE '10G', MAX_SESSION_NUM 64, MIN_CPU=1, MIN_MEMORY='5G', MIN_IOPS=128; obclient> CREATE RESOURCE POOL pool2 unit = 'unit2', unit_num = 1, zone_list=('z4','z5');Add resource pools for the tenant to zones
z4andz5.obclient> ALTER TENANT tenant1 RESOURCE_POOL_LIST =('pool1', 'pool2') ;
Modify the locality of the tenant to add replicas.
Based on the locality modification rule, you can add only one zone at a time. For more information about the locality modification rule, see Overview of localities.
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';