Purpose
The ALTER TENANT statement is used to modify the attributes of a user tenant, including the locality, primary zone, resource pool list, and system variable values.
To rename a user tenant, you can use the ALTER TENANT ... RENAME statement.
To lock or unlock a user tenant, you can use the ALTER TENANT ... LOCK / UNLOCK statement. After executing the ALTER TENANT ... LOCK statement to lock a tenant, the system will prevent users from creating new connections to the locked tenant. Existing connections are not affected.
Privilege requirements
Only the root user of the sys tenant (root@sys) can modify a tenant. Modifying tenants is not supported for other tenants.
Syntax
ALTER TENANT
ALTER TENANT tenant_name
[SET] [tenant_option_list] [set_sys_var];
tenant_option_list:
tenant_option [, tenant_option ...]
tenant_option:
LOCALITY [=] 'locality_description'
| PRIMARY_ZONE [=] zone
| RESOURCE_POOL_LIST [=](pool_name [, pool_name...])
| ENABLE_ARBITRATION_SERVICE [=] {True | False}
| [DEFAULT] TABLEGROUP [=] {NULL | tablegroup_name}
| ENABLE_EXTENDED_ROWID [=] {true | false}
| COMMENT [=]'string'
set_sys_var:
VARIABLES var_name {TO | =} var_value [,var_name {TO | =} var_value...]
ALTER TENANT ... RENAME
ALTER TENANT tenant_name RENAME GLOBAL_NAME TO new_tenant_name;
ALTER TENANT ... LOCK / UNLOCK
ALTER TENANT tenant_name LOCK | UNLOCK;
Parameters
Parameters |
Description |
|---|---|
| tenant_name | Specifies the name of the tenant to be modified. |
| LOCALITY | Modify the locality of a tenant. Locality describes how replicas are distributed across zones. The current version supports the following replica types: Full-featured replica: The name is FULL, abbreviated as F. For more information about full-featured replicas, see Full-featured replicas. Example: LOCALITY = 'F@z1,F@z2,F@z3'When modifying this parameter, if you need to add zones, the tenant resource pool must have sufficient resources. ZONE_LIST contains this zone. |
| PRIMARY_ZONE | Modify the primary zone of a tenant. Valid values:
If no primary zone is specified when creating the tenant, the default value is RANDOM. |
| RESOURCE_POOL_LIST | Modify the tenant's resource pool list. If there are multiple resource pools, ensure that the number of UNIT_NUM is the same for all resource pools.
Note
|
| ENABLE_ARBITRATION_SERVICE | No action is required at this time. |
| [DEFAULT] TABLEGROUP | Modifies the default table group information of a tenant. NULL indicates to cancel the default table group. |
| ENABLE_EXTENDED_ROWID | Specifies whether to enable Extended ROWID mode for all tables in the tenant. Once enabled, this parameter cannot be disabled. However, you can use the tenant-level parameter default_enable_extended_rowid to specify whether to enable Extended ROWID mode for newly created tables. For more information about this tenant-level parameter, see default_enable_extended_rowid. |
| system_var_name | Modify the system variable value of a tenant. |
| RENAME GLOBAL_NAME TO | Modify the tenant name. |
| COMMENT | Modify the comment. |
Examples
Change the primary zone of tenant
tenant1tozone2.obclient [oceanbase]> ALTER TENANT tenant1 primary_zone='zone2';Change the primary zone of tenant
tenant1toRANDOM.obclient [oceanbase]> ALTER TENANT tenant1 primary_zone = RANDOM;Assuming the tenant has three zones:
zone1,zone2, andzone3, this statement is equivalent toobclient [oceanbase]> ALTER TENANT tenant1 primary_zone = 'zon1,zone2,zone3';Modifying a resource pool is typically used in scenarios where the number of tenant replicas needs to be upgraded or downgraded. When modifying a resource pool, you can only add or remove one resource pool at a time. You cannot execute the following statement to directly replace the tenant's resource pool
pool1withpool2, otherwise the following error will occur.obclient [oceanbase]> ALTER TENANT tenant1 resource_pool_list=('pool2');The error message is as follows:
ERROR 1210 (HY000): Incorrect arguments to resource pool listIf you want to adjust the resources available to a tenant, for example, to scale out the tenant, you can increase the specification of its resource units.
obclient [oceanbase]> ALTER RESOURCE UNIT unit1 MAX_CPU 15, MEMORY_SIZE '20G', MAX_IOPS 1280, MIN_CPU=10, MIN_IOPS=1024;Modify the locality of tenant
tenant1and increase the number of replicas. Here,Findicates that the replica type is a full-featured replica, andB_4is the name of the new zone.Assume the current tenant
tenant1has a locality ofF@B_1,F@B_2,F@B_3, a resource pool ofpool1, and itsZONE_LISTscope is'B_1','B_2','B_3'.Create the resource unit
unit2.obclient [oceanbase]> CREATE RESOURCE UNIT unit2, MAX_CPU=5, MIN_CPU=2.5, MEMORY_SIZE= '32G', MAX_IOPS=10000, MIN_IOPS=5000, LOG_DISK_SIZE=5301023539200;Create a resource pool named
pool2.obclient [oceanbase]> CREATE RESOURCE POOL pool2 unit='unit2',unit_num=1,zone_list=('B_4');Add the resource pool
pool2to the tenant.obclient [oceanbase]> ALTER TENANT tenant1 resource_pool_list=('pool1','pool2');Modify the tenant's locality.
obclient [oceanbase]> ALTER TENANT tenant1 LOCALITY='F@B_1,F@B_2,F@B_3,F@B_4';