This topic describes how to modify the number of primary zones for a tenant to implement tenant scaling.
Prerequisites
Before you modify the number of primary zones for a tenant, enable load balancing for the tenant. The tenant-level parameter enable_rebalance specifies whether to enable load balancing for a tenant. You can specify this parameter in the sys tenant to control whether to enable load balancing among tenants, and specify this parameter in a user tenant to control whether to enable load balancing for the current tenant. The default value is true. The setting takes effect immediately without the need to restart the OBServer node.
You can execute one of the following statements to enable load balancing for a tenant:
Enable load balancing for a specified tenant from the sys tenant
ALTER SYSTEM SET enable_rebalance = true TENANT = 'tenant_name';This statement only sets the value of the
enable_rebalanceparameter totruefor the specified user tenant.Here is an example:
ALTER SYSTEM SET enable_rebalance = true TENANT = 'mq_t1';Enable load balancing among tenants and for each tenant from the sys tenant
ALTER SYSTEM SET enable_rebalance = true TENANT = ALL;This statement sets the value of the
enable_rebalanceparameter totruefor the sys tenant and all user tenants.Enable load balancing for a user tenant from the current tenant
ALTER SYSTEM SET enable_rebalance = true;
For more information about the enable_rebalance parameter, see enable_rebalance.
Add a primary zone
Log on to the
systenant of the cluster as therootuser.obclient -h172.30.xxx.xxx -P2883 -uroot@sys -pxxxx -AAccess the database named
oceanbase.use oceanbase;Query the basic information about the
mq_t1tenant, such as thelocalityandprimary zone.SELECT * FROM oceanbase.DBA_OB_TENANTS WHERE tenant_id = 1004;A sample query result is as follows:
+-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED | TENANT_ROLE | SWITCHOVER_STATUS | SWITCHOVER_EPOCH | SYNC_SCN | REPLAYABLE_SCN | READABLE_SCN | RECOVERY_UNTIL_SCN | LOG_MODE | ARBITRATION_SERVICE_STATUS | UNIT_NUM | COMPATIBLE | +-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ | 1004 | mq_t1 | USER | 2023-07-01 19:16:39.739258 | 2023-07-03 14:39:47.409845 | zone1;zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL | ORACLE | NORMAL | NO | NO | PRIMARY | NORMAL | 0 | 1688366766761651752 | 1688366766761651752 | 1688366766761651751 | 4611686018427387903 | NOARCHIVELOG | DISABLED | 2 | 4.2.0.0 | +-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ 1 row in setQuery the number of resource units of the
mq_t1tenant. In this example, the tenant has two resource units in each zone.SELECT * FROM oceanbase.DBA_OB_UNITS WHERE tenant_id = 1004;A sample query result is as follows:
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | UNIT_ID | TENANT_ID | STATUS | RESOURCE_POOL_ID | UNIT_GROUP_ID | CREATE_TIME | MODIFY_TIME | ZONE | SVR_IP | SVR_PORT | MIGRATE_FROM_SVR_IP | MIGRATE_FROM_SVR_PORT | MANUAL_MIGRATE | UNIT_CONFIG_ID | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1008 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.723840 | 2023-07-01 19:16:39.744524 | zone1 | xx.xx.xx.198 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1010 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.727011 | 2023-07-01 19:16:39.744524 | zone2 | xx.xx.xx.197 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1012 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.731235 | 2023-07-01 19:16:39.745584 | zone3 | xx.xx.xx.192 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1016 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.298237 | 2023-07-03 14:23:00.298237 | zone1 | xx.xx.xx.196 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1017 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.300350 | 2023-07-03 14:23:00.300350 | zone2 | xx.xx.xx.194 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1018 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.302460 | 2023-07-03 14:23:00.302460 | zone3 | xx.xx.xx.64 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ 6 rows in setChange the value of the
PRIMARY_ZONEattribute from 1 to 2 for themq_t1tenant.ALTER TENANT mq_t1 PRIMARY_ZONE='zone1,zone2;zone3';Query the basic information of the
mq_t1tenant. The zones with the highest priority change fromzone1tozone1,zone2. This indicates that thePRIMARY_ZONEattribute is successfully modified.SELECT * FROM oceanbase.DBA_OB_TENANTS WHERE tenant_id = 1004;A sample query result is as follows:
+-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED | TENANT_ROLE | SWITCHOVER_STATUS | SWITCHOVER_EPOCH | SYNC_SCN | REPLAYABLE_SCN | READABLE_SCN | RECOVERY_UNTIL_SCN | LOG_MODE | ARBITRATION_SERVICE_STATUS | UNIT_NUM | COMPATIBLE | +-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ | 1004 | mq_t1 | USER | 2023-07-01 19:16:39.739258 | 2023-07-03 14:52:38.639769 | zone1,zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL | ORACLE | NORMAL | NO | NO | PRIMARY | NORMAL | 0 | 1688367181014913489 | 1688367181014913489 | 1688367181014913488 | 4611686018427387903 | NOARCHIVELOG | DISABLED | 2 | 4.2.0.0 | +-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ 1 row in setQuery the resource units of the
mq_t1tenant. In this example, the number of resource units remains unchanged.SELECT * FROM oceanbase.DBA_OB_UNITS WHERE tenant_id = 1004;A sample query result is as follows:
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | UNIT_ID | TENANT_ID | STATUS | RESOURCE_POOL_ID | UNIT_GROUP_ID | CREATE_TIME | MODIFY_TIME | ZONE | SVR_IP | SVR_PORT | MIGRATE_FROM_SVR_IP | MIGRATE_FROM_SVR_PORT | MANUAL_MIGRATE | UNIT_CONFIG_ID | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1008 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.723840 | 2023-07-01 19:16:39.744524 | zone1 | xx.xx.xx.198 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1010 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.727011 | 2023-07-01 19:16:39.744524 | zone2 | xx.xx.xx.197 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1012 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.731235 | 2023-07-01 19:16:39.745584 | zone3 | xx.xx.xx.192 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1016 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.298237 | 2023-07-03 14:23:00.298237 | zone1 | xx.xx.xx.196 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1017 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.300350 | 2023-07-03 14:23:00.300350 | zone2 | xx.xx.xx.194 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1018 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.302460 | 2023-07-03 14:23:00.302460 | zone3 | xx.xx.xx.64 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ 6 rows in set
In the preceding example, the number of primary zones is changed from 1 to 2 for the mq_t1 tenant. The tenant has two resource units in each zone before the change. After the change, the tenant still has two resource units in each zone but the number of primary zones changes from 1 to 2.
Remove a primary zone
Log on to the
systenant of the cluster as therootuser.obclient -h172.30.xxx.xxx -P2883 -uroot@sys -pxxxx -AAccess the database named
oceanbase.use oceanbase;Query the basic information about the
mq_t1tenant, such as thelocalityandprimary zone.SELECT * FROM oceanbase.DBA_OB_TENANTS WHERE tenant_id = 1004;A sample query result is as follows:
+-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED | TENANT_ROLE | SWITCHOVER_STATUS | SWITCHOVER_EPOCH | SYNC_SCN | REPLAYABLE_SCN | READABLE_SCN | RECOVERY_UNTIL_SCN | LOG_MODE | ARBITRATION_SERVICE_STATUS | UNIT_NUM | COMPATIBLE | +-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ | 1004 | mq_t1 | USER | 2023-07-01 19:16:39.739258 | 2023-07-03 14:34:26.944961 | zone1,zone2;zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL | ORACLE | NORMAL | NO | NO | PRIMARY | NORMAL | 0 | 1688366177567368939 | 1688366177567368939 | 1688366177432837207 | 4611686018427387903 | NOARCHIVELOG | DISABLED | 2 | 4.2.0.0 | +-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ 1 row in setQuery the number of resource units of the
mq_t1tenant. In this example, the tenant has two resource units in each zone.SELECT * FROM oceanbase.DBA_OB_UNITS WHERE tenant_id = 1004;A sample query result is as follows:
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | UNIT_ID | TENANT_ID | STATUS | RESOURCE_POOL_ID | UNIT_GROUP_ID | CREATE_TIME | MODIFY_TIME | ZONE | SVR_IP | SVR_PORT | MIGRATE_FROM_SVR_IP | MIGRATE_FROM_SVR_PORT | MANUAL_MIGRATE | UNIT_CONFIG_ID | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1008 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.723840 | 2023-07-01 19:16:39.744524 | zone1 | xx.xx.xx.198 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1010 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.727011 | 2023-07-01 19:16:39.744524 | zone2 | xx.xx.xx.197 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1012 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.731235 | 2023-07-01 19:16:39.745584 | zone3 | xx.xx.xx.192 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1016 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.298237 | 2023-07-03 14:23:00.298237 | zone1 | xx.xx.xx.196 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1017 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.300350 | 2023-07-03 14:23:00.300350 | zone2 | xx.xx.xx.194 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1018 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.302460 | 2023-07-03 14:23:00.302460 | zone3 | xx.xx.xx.64 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ 6 rows in setChange the value of the
PRIMARY_ZONEattribute from 2 to 1 for themq_t1tenant.ALTER TENANT mq_t1 PRIMARY_ZONE='zone1;zone2,zone3';Query the basic information of the
mq_t1tenant. The zones with the highest priority change fromzone1,zone2tozone1. This indicates that thePRIMARY_ZONEattribute is successfully modified.SELECT * FROM oceanbase.DBA_OB_TENANTS WHERE tenant_id = 1004;A sample query result is as follows:
+-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED | TENANT_ROLE | SWITCHOVER_STATUS | SWITCHOVER_EPOCH | SYNC_SCN | REPLAYABLE_SCN | READABLE_SCN | RECOVERY_UNTIL_SCN | LOG_MODE | ARBITRATION_SERVICE_STATUS | UNIT_NUM | COMPATIBLE | +-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ | 1004 | mq_t1 | USER | 2023-07-01 19:16:39.739258 | 2023-07-03 15:02:28.600516 | zone1;zone2,zone3 | FULL{1}@zone1, FULL{1}@zone2, FULL{1}@zone3 | NULL | ORACLE | NORMAL | NO | NO | PRIMARY | NORMAL | 0 | 1688367783544758489 | 1688367783544758489 | 1688367783544758488 | 4611686018427387903 | NOARCHIVELOG | DISABLED | 2 | 4.2.0.0 | +-----------+-------------+-------------+----------------------------+----------------------------+-------------------+---------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+----------+------------+ 1 row in setQuery information about the resource units of the
mq_t1tenant. The number of resource units remains unchanged after the change.SELECT * FROM oceanbase.DBA_OB_UNITS WHERE tenant_id = 1004;A sample query result is as follows:
+---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | UNIT_ID | TENANT_ID | STATUS | RESOURCE_POOL_ID | UNIT_GROUP_ID | CREATE_TIME | MODIFY_TIME | ZONE | SVR_IP | SVR_PORT | MIGRATE_FROM_SVR_IP | MIGRATE_FROM_SVR_PORT | MANUAL_MIGRATE | UNIT_CONFIG_ID | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1008 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.723840 | 2023-07-01 19:16:39.744524 | zone1 | xx.xx.xx.198 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1010 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.727011 | 2023-07-01 19:16:39.744524 | zone2 | xx.xx.xx.197 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1012 | 1004 | ACTIVE | 1002 | 1002 | 2023-07-01 19:15:09.731235 | 2023-07-01 19:16:39.745584 | zone3 | xx.xx.xx.192 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1016 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.298237 | 2023-07-03 14:23:00.298237 | zone1 | xx.xx.xx.196 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1017 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.300350 | 2023-07-03 14:23:00.300350 | zone2 | xx.xx.xx.194 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | | 1018 | 1004 | ACTIVE | 1002 | 1006 | 2023-07-03 14:23:00.302460 | 2023-07-03 14:23:00.302460 | zone3 | xx.xx.xx.64 | 2882 | NULL | NULL | NULL | 1001 | 2 | 2 | 5368709120 | 16106127360 | 20000 | 20000 | 2 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+-------+----------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ 6 rows in set
In the preceding example, the number of primary zones is changed from 2 to 1 for the mq_t1 tenant. The tenant has two resource units in each zone before the change. After the change, the tenant still has two resource units in each zone but the number of primary zones changes from 2 to 1.