OceanBase AI Database supports modifying the attributes of a user tenant, such as the number of replicas, zone list, primary zone, and system variable values. This topic describes the modification procedure.
Background information
Tenant attribute modifications involve the following common scenarios:
Modify the primary zone: The primary zone describes the preferred location of leader replicas, which handle strong-consistency read and write traffic. Therefore, the primary zone determines the traffic distribution in OceanBase AI Database. You can modify the primary zone to switch business traffic from one IDC to another or from one city to another in disaster recovery and scaling scenarios.
Modify the locality: The locality of a tenant describes the types and distribution of replicas. You can modify the locality to adjust the deployment architecture of the tenant in scenarios such as migrating a cluster from one IDC to another or adjusting the disaster recovery level.
Procedure
Log in to the
systenant of the cluster as therootuser.obclient -h172.30.xx.xx -P2883 -uroot@sys#cluster -p**** -AAccess the database named
oceanbase.obclient(root@sys)[(none)]> USE oceanbase;Query the
DBA_OB_TENANTSview for the configuration information of a tenant.To query the configuration information of the
mq_t1tenant, execute the following statement:obclient(root@sys)[oceanbase]> SELECT TENANT_ID, TENANT_NAME, TENANT_TYPE, CREATE_TIME, MODIFY_TIME, PRIMARY_ZONE, LOCALITY, COMPATIBILITY_MODE, STATUS FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'mq_t1';The query result is as follows:
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+--------------------+--------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | COMPATIBILITY_MODE | STATUS | +-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+--------------------+--------+ | 1006 | mq_t1 | USER | 2023-05-18 15:48:57.447657 | 2023-05-18 15:49:12.857944 | zone1;zone2 | FULL{1}@zone1, FULL{1}@zone2 | MYSQL | NORMAL | +-----------+-------------+-------------+----------------------------+----------------------------+--------------+------------------------------+--------------------+--------+ 1 row in setFor more information about the
DBA_OB_TENANTSview, see DBA_OB_TENANTS.Execute the
ALTER TENANTstatement to modify the attributes of the tenant.Notice
You must execute this statement as the `root` user in the `sys` tenant.
The syntax is as follows:
ALTER TENANT {tenant_name | all } [SET] [tenant_option_list] [opt_global_sys_vars_set] tenant_option_list: tenant_option [, tenant_option ...] tenant_option: COMMENT [=]'string' |PRIMARY_ZONE [=] zone |RESOURCE_POOL_LIST [=](poolname [, poolname...]) |DEFAULT TABLEGROUP [=] {NULL | tablegroupname} |LOCALITY [=] 'locality description'; opt_global_sys_vars_set: VARIABLES system_var_name = expr [,system_var_name = expr] ...where:
{tenant_name | all }: the name of the tenant.allindicates all tenants.PRIMARY_ZONE: the primary zone of the tenant.RESOURCE_POOL_LIST: the resource pool list. You can add or remove only one resource pool at a time.LOCALITY: the distribution of replicas in zones. For example,F@zone1,F@zone2indicates thatzone1andzone2are all full-featured replicas. To add a zone in this parameter, make sure that the zone is in the zone list specified byZONE_LIST.
For detailed information about the
ALTER TENANTstatement, see ALTER TENANT.Here are some examples:
Change the primary zone of the
mq_t1tenant to"zone1,zone2", and the locality to"F@zone1,F@zone2".obclient(root@sys)[oceanbase]> ALTER TENANT mq_t1 PRIMARY_ZONE='zone1,zone2';obclient(root@sys)[oceanbase]> ALTER TENANT mq_t1 LOCALITY="F@zone1,F@zone2";You can add or remove only one resource pool at a time for a tenant. You cannot directly replace the resource pool of the tenant. Assume that the original resource pool of the tenant is
mq_pool_01. If you execute the following statement to replace the original resource pool withmq_pool_02, the system returns an error.obclient(root@sys)[oceanbase]> ALTER TENANT mq_t1 RESOURCE_POOL_LIST=('mq_pool_02'); ERROR 1210 (HY000): Incorrect arguments to resource pool list
Query related views to verify the modification results.
The modifications on the primary zone and locality take effect asynchronously. You need to query related views to confirm whether the modifications take effect.
- You can query the
DBA_OB_TENANTSview for the primary zone and locality of the tenant. In the view, thePRIMARY_ZONEfield indicates the primary zone value configured by the user,LOCALITYindicates the locality value configured by the user, andPREVIOUS_LOCALITYindicates the locality value before the modification. If the value ofPREVIOUS_LOCALITYis not empty, the modification on the locality has not taken effect. If the value ofPREVIOUS_LOCALITYis empty, the modification on the locality has taken effect. - You can query the
CDB_OB_TABLE_LOCATIONSview in thesystenant for the distribution of tables and partitions in a tenant, and query theDBA_OB_TABLE_LOCATIONSview in a user tenant for the distribution of tables and partitions in this user tenant. The modification results of the primary zone and locality are indicated in these views.
- You can query the