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. Existing connections are not 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, 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 resource pool list of the tenant. If there are multiple resource pools, the number of UNIT_NUM for each resource pool must be consistent.
Notice
|
| ENABLE_ARBITRATION_SERVICE | In scenarios where the arbitration service is deployed, modifies the enablement status of the tenant's arbitration service. |
| [DEFAULT] TABLEGROUP | Modifies the default table group information of 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 system variable value of the tenant. |
| RENAME GLOBAL_NAME TO | Modifies the tenant name. |
| COMMENT | Modifies the comment. |
Examples
Modify the primary zone of the
tenant1tenant tozone2.obclient [oceanbase]> ALTER TENANT tenant1 primary_zone='zone2';Modify the primary zone of the
tenant1tenant toRANDOM.obclient [oceanbase]> ALTER TENANT tenant1 primary_zone = RANDOM;Assuming that the tenant has three zones:
zone1,zone2, andzone3, the preceding statement is equivalent to the following statement:obclient [oceanbase]> ALTER TENANT tenant1 primary_zone = 'zon1,zone2,zone3';Modifying a resource pool is typically used for scenarios where you want to scale the number of replicas of a tenant up or down. However, when you modify a resource pool, you can only add or delete one resource pool at a time. You cannot directly replace the resource pool
pool1of a tenant withpool2by executing the following statement. Otherwise, an error is returned.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 by scaling it out, 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. In this example,Findicates a full-featured replica, andB_4is the name of the newly added zone.Assume that 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 thetenant1tenant.obclient [oceanbase]> ALTER TENANT tenant1 resource_pool_list=('pool1','pool2');Modify the locality of the
tenant1tenant.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 locality of the
tenant1tenant is as follows:obclient [oceanbase]> ALTER TENANT tenant1 LOCALITY = 'F@B_1,F@B_2,F@B_3,C@B_4';Notice
- When you modify the locality of a tenant, you can only add or remove columnstore replicas. You cannot convert the replica type. That is, if you want to add a columnstore replica, there must be no replica in the original zone. If you want to remove a columnstore replica, you must change the zone that contains the columnstore replica to a zone with no replicas.
- After you add a columnstore replica to a tenant, you need to deploy an ODP and perform a series of configurations to route the connection to the columnstore replica. For more information about columnstore replicas, see Columnstore replicas.
If the arbitration service is deployed, enable the arbitration service for the
tenant1tenant.obclient [oceanbase]> ALTER TENANT tenant1 ENABLE_ARBITRATION_SERVICE=true;Rename the
tenant1tenant totenant101.obclient [oceanbase]> ALTER TENANT tenant1 RENAME GLOBAL_NAME TO tenant101;Lock the
tenant1tenant.obclient [oceanbase]> ALTER TENANT tenant1 LOCK;
