This topic describes how to modify the settings of a tenant.
Modify a tenant by using an SQL statement
After a tenant is created, you can modify information about the tenant by using an SQL statement, including the number of replicas, zone list, primary zone, and system variables of the tenant.
The SQL syntax for modifying a tenant 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] ...
Some notes about this:
The preceding statement can be executed only by the administrator user of the
systenant, such asroot@sys.ALLindicates to modify all tenants.PRIMARY_ZONEspecifies the primary zone of the tenant.RESOURCE_POOL_LISTspecifies the list of resource pools. You can add or delete only one resource pool at a time.You cannot directly replace the resource pool of the tenant. Assume that the resource pool used by the tenant is
pool1. The system returns an error if you execute the following statement to replace the resource pool withpool2:obclient> ALTER TENANT tenant1 resource_pool_list=('pool2'); ERROR 1210 (HY000): Incorrect arguments to resource pool listDEFAULT TABLEGROUPspecifies the default table group of the tenant. If this parameter is set toNULL, the default table group of the database is disabled.LOCALITYspecifies the distribution of replicas across zones. For example,F@z1,F@z2,F@z3,R@z4indicates thatz1,z2, andz3are full-featured replicas, andz4is a read-only replica.
Examples:
Change the primary zone of
tenant1tozone2.obclient> ALTER TENANT tenant1 primary_zone='zone2';Modify the locality of
tenant1to increase the number of replicas.Here,
Findicates a full-featured replica, andB_4is the name of the zone to be created.obclient> ALTER TENANT tenant1 locality="F@B_1,F@B_2,F@B_3,F@B_4"
For more information about the ALTER TENANT statement, see ALTER TENANT.
Modify the primary zone of a tenant in the OCP console
Partition leaders of a tenant are distributed based on the primary zone. You can modify zone priorities in the OceanBase Cloud Platform (OCP) console to modify the primary zone of the tenant.
Prerequisites
You are granted the system administrator, OCP tenant administrator role, or another role that has permissions to manage the cluster. Otherwise, request the administrator to assign the required role. For more information, see "Edit a user" in the OCP User Guide of the corresponding version.
Modify zone priorities
Log on to the OCP console.
In the left-side navigation pane, click Tenants to go to the Tenants page.
In the Tenants list, find the target tenant and click its name to go to its details page.
In the Primary Zone section, click Modify. In the dialog box that appears on the right, you can modify the zone priorities.
Click OK.