Purpose
You can use this statement to modify the attributes of a user tenant, including the locality, primary zone, resource pool list, and system variable values.
You can use the ALTER TENANT ... RENAME statement to rename a user tenant.
You can use the ALTER TENANT ... LOCK/UNLOCK statement to lock or unlock a user tenant. After you lock a tenant, you cannot create a connection on the tenant. However, existing connections are not affected.
Required privileges
You can modify the attributes of a tenant only as the root user of the sys tenant (namely root@sys).
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 | The name of the tenant to be modified. |
| LOCALITY | The locality of the tenant. Locality describes how the replicas are distributed across zones. The following replica types are supported in the current version:
Examples: LOCALITY = 'F@z1,F@z2,F@z3', LOCALITY = 'F@z1,R@z2,C@z3'When you modify this parameter, if you want to add a zone, the ZONE_LIST of the tenant resource pool must contain the zone. |
| PRIMARY_ZONE | Modifies the primary zone of the tenant. Valid values:
If you do not specify this parameter when you create a tenant, the default value RANDOM is used. |
| RESOURCE_POOL_LIST | Modifies the resource pool list of the tenant. If the tenant has multiple resource pools, they must have the same UNIT_NUM value, which indicates the number of resource units.
Notice
|
| ENABLE_ARBITRATION_SERVICE | Modifies the enabling status of the arbitration service, if it is deployed for the tenant. |
| [DEFAULT] TABLEGROUP | Modifies the default table group of the tenant. The value NULL specifies to disable the default table group. |
| ENABLE_EXTENDED_ROWID | Specifies whether to enable the Extended ROWID mode for all tables in the tenant. After you enable this mode, it cannot be disabled. However, you can use the tenant-level parameter default_enable_extended_rowid to specify whether to enable the Extended ROWID mode for tables created later. For more information about the default_enable_extended_rowid parameter, see default_enable_extended_rowid. |
| system_var_name | Modifies the system variable values of the tenant. |
| RENAME GLOBAL_NAME TO | Renames the tenant. |
| COMMENT | Modifies the comment. |
Examples
Change the primary zone of
tenant1tozone2.obclient [oceanbase]> ALTER TENANT tenant1 primary_zone='zone2';You need to modify the resource pool list generally when you increase or decrease the number of replicas for a tenant. When you modify the resource pool list for a tenant, you can add or remove only one resource pool at a time. You cannot directly replace one resource pool with another.
obclient [oceanbase]> ALTER TENANT tenant1 resource_pool_list=('pool2');If you execute the preceding statement to replace the
pool1resource pool with thepool2resource pool, the following error message will be returned:ERROR 1210 (HY000): Incorrect arguments to resource pool listIf you want to increase the available resources of a tenant, you can upgrade the unit config of the resource units of the tenant.
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
tenant1to increase the number of replicas.Findicates a full-featured replica, andB_4is the name of the zone to be created.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 resource pool
pool2to the resource pool list of the tenant.obclient [oceanbase]> ALTER TENANT tenant1 resource_pool_list=('pool1','pool2');Modify the locality of the tenant.
obclient [oceanbase]> ALTER TENANT tenant1 LOCALITY='F@B_1,F@B_2,F@B_3,F@B_4';If the replica to be added is a columnstore replica, the statement for modifying 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, for columnstore replicas, only add or reduce replicas, but not change the replica type. That is, if you want to add columnstore replicas, ensure that no replica exists in the original zone. If you want to reduce columnstore replicas, change the zone where the columnstore replicas are located to a zone without replicas.
- After you add columnstore replicas to a tenant, you must deploy an ODP and perform a series of configurations to route the connection to the columnstore replicas. For more information about columnstore replicas, see Columnstore replicas.
If the arbitration service is deployed, enable the arbitration service for
tenant1.obclient [oceanbase]> ALTER TENANT tenant1 ENABLE_ARBITRATION_SERVICE=true;Rename the
tenant1tenant astenant101.obclient [oceanbase]> ALTER TENANT tenant1 RENAME GLOBAL_NAME TO tenant101;Lock the
tenant1tenant.obclient [oceanbase]> ALTER TENANT tenant1 LOCK;