Purpose
The ALTER TENANT statement is used to modify the properties of a user tenant, including the Locality, primary zone, resource pool list, and system variable values.
To modify the name of 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, the system will no longer allow users to create new connections to the locked tenant, but existing connections will remain unaffected.
Privilege requirements
Only the root user of the sys tenant (root@sys) can modify a tenant. Other tenants do not support modifying 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
| Parameter | Description |
|---|---|
| tenant_name | Specifies the name of the tenant to be modified. |
| LOCALITY | Modifies the Locality of the tenant. Locality describes the distribution of replicas across zones, for example: F@z1,F@z2,F@z3 indicates that z1, z2, and z3 are full-featured replicas.When modifying this parameter, if you need to add a zone, the ZONE_LIST of the tenant's resource pool must include that zone. |
| PRIMARY_ZONE | Modifies the primary zone of the tenant. The supported values are as follows:
If the primary zone is not specified when creating the tenant, the default value is RANDOM. |
| RESOURCE_POOL_LIST | Modifies the list of resource pools for the tenant. If there are multiple resource pools, the UNIT_NUM of each resource pool must be consistent.
Notice
|
| ENABLE_ARBITRATION_SERVICE | In scenarios where the arbitration service is deployed, modifies the status of the arbitration service for the tenant. |
| [DEFAULT] TABLEGROUP | Modifies the default table group information for the tenant. NULL indicates that the default table group is canceled. |
| ENABLE_EXTENDED_ROWID | Specifies whether to enable the Extended ROWID mode for all tables in the tenant. Once enabled, this mode cannot be disabled. However, you can use the tenant-level configuration item default_enable_extended_rowid to specify whether to enable the Extended ROWID mode for newly created tables. |
| system_var_name | Modifies the value of a system variable for the tenant. |
| RENAME GLOBAL_NAME TO | Modifies the tenant name. |
| COMMENT | Modifies 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;If the tenant has three zones,
zone1,zone2, andzone3, the preceding statement is equivalent toobclient [oceanbase]> ALTER TENANT tenant1 primary_zone = 'zon1,zone2,zone3';Modifying a resource pool is typically used in scenarios where you want to upgrade or downgrade the number of replicas for a tenant. When modifying a resource pool, you can only add or remove one resource pool at a time. You cannot directly replace the resource pool
pool1of a tenant withpool2using the following statement, 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 available resources for a tenant, such as expanding the tenant, you can increase the specifications of the resource units.
obclient [oceanbase]> ALTER RESOURCE UNIT unit1 MAX_CPU 15, MEMORY_SIZE '20G', MAX_IOPS 1280, MIN_CPU=10, MIN_IOPS=1024;Change the locality of tenant
tenant1to add replicas. In this example,Findicates a full-featured replica, andB_4is the name of the new zone.Create a resource unit named
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');Change the locality of the tenant.
obclient [oceanbase]> ALTER TENANT tenant1 locality="F@B_1,F@B_2,F@B_3,F@B_4";
In a scenario where an arbitration service is deployed, enable the arbitration service for
tenant1.obclient [oceanbase]> ALTER TENANT tenant1 ENABLE_ARBITRATION_SERVICE=true;Rename the name of the regular tenant
tenant1totenant101.obclient [oceanbase]> ALTER TENANT tenant1 RENAME GLOBAL_NAME TO tenant101;Lock the tenant
tenant1.obclient [oceanbase]> ALTER TENANT tenant1 LOCK;