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.
If you need to modify the name of a user tenant, you can use the ALTER TENANT ... RENAME statement.
If you need 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 not be affected.
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. The supported replica types in the current version are as follows:
Example: LOCALITY = 'F@z1,F@z2,F@z3' or LOCALITY = 'F@z1,R@z2,C@z3'When modifying this parameter, if you need to add a zone, it must be included in the ZONE_LIST of the tenant's resource pool. |
| 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. For multiple resource pools, the number of UNIT_NUM must be consistent across all pools.
Notice
|
| ENABLE_ARBITRATION_SERVICE | In a scenario 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 parameter 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. For more information about the tenant-level configuration item default_enable_extended_rowid, see default_enable_extended_rowid. |
| system_var_name | Modifies the value of a system variable for the tenant. |
| RENAME GLOBAL_NAME TO | Modifies the name of the tenant. |
| COMMENT | Modifies the comment. |
Examples
Change the primary zone of the
tenant1tenant tozone2.obclient [oceanbase]> ALTER TENANT tenant1 primary_zone='zone2';Change the primary zone of the
tenant1tenant toRANDOM.obclient [oceanbase]> ALTER TENANT tenant1 primary_zone = RANDOM;Assuming the tenant has three zones named
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 you need to upgrade or downgrade the number of replicas for a tenant. However, when modifying a resource pool, you can only add or remove one resource pool at a time. You cannot directly replace the tenant's resource pool
pool1withpool2using the following statement, or 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 the 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;Modify the locality of the
tenant1tenant to add more replicas. Here,Findicates a full-featured replica, andB_4is the name of the new zone.Assuming the current locality of the
tenant1tenant isF@B_1,F@B_2,F@B_3, the resource pool ispool1, and theZONE_LISTrange is'B_1','B_2','B_3'.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
pool2resource pool to 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';If the replica type to be added is a columnstore replica, the statement to modify the tenant's locality is as follows:
obclient [oceanbase]> ALTER TENANT tenant1 LOCALITY = 'F@B_1,F@B_2,F@B_3,C@B_4';Notice
- When modifying the locality of a tenant, for columnstore replicas, you can only add or remove replicas. You cannot convert the replica type. That is, if you want to add a columnstore replica, there must be no replicas in the original zone. If you want to remove a columnstore replica, you can only change the zone that contains the columnstore replica to a zone without any replicas.
- After adding a columnstore replica to the tenant, you need to deploy an ODP and configure it to route connections to the columnstore replica. For more information about columnstore replicas, see Columnstore replicas.
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 ordinary tenant
tenant1totenant101.obclient [oceanbase]> ALTER TENANT tenant1 RENAME GLOBAL_NAME TO tenant101;Lock the
tenant1tenant.obclient [oceanbase]> ALTER TENANT tenant1 LOCK;