This topic describes how to modify the number of primary zones for a tenant to implement tenant scaling.
Add a primary zone
Log on to the sys tenant of the cluster as the root user.
obclient -h172.30.xxx.xxx -P2883 -uroot@sys -pxxxx -AExecute the following statement to go to the database named
oceanbase:obclient>use oceanbase;Query the basic information about the
mq_t1tenant, such aslocalityandprimary zone.obclient> SELECT * FROM oceanbase.DBA_OB_TENANTS WHERE tenant_id = 1004; +-----------+-------------+-------------+----------------------------+----------------------------+----------------------------------------+------------------------------------------------------------------+-------------------+--------------------+--------+---------------+--------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED | +-----------+-------------+-------------+----------------------------+----------------------------+----------------------------------------+------------------------------------------------------------------+-------------------+--------------------+--------+---------------+--------+ | 1004 | mq_t1 | USER | 2023-01-04 18:32:08.212745 | 2023-01-04 18:32:33.343667 | sa128_obv4_1;sa128_obv4_2,sa128_obv4_3 | FULL{1}@sa128_obv4_1, FULL{1}@sa128_obv4_2, FULL{1}@sa128_obv4_3 | NULL | MYSQL | NORMAL | NO | NO | +-----------+-------------+-------------+----------------------------+----------------------------+----------------------------------------+------------------------------------------------------------------+-------------------+--------------------+--------+---------------+--------+ 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.obclient> SELECT * FROM oceanbase.DBA_OB_UNITS WHERE tenant_id = 1004; +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+-------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 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 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+-------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1004 | 1004 | ACTIVE | 1005 | 1003 | 2023-01-04 11:48:36.582413 | 2023-01-04 18:32:08.215935 | sa128_obv4_1 | xx.xx.xx.xx | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | | 1005 | 1004 | ACTIVE | 1005 | 1003 | 2023-01-04 11:48:36.591414 | 2023-01-04 18:32:08.215935 | sa128_obv4_2 | xx.xx.xx.xx | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | | 1006 | 1004 | ACTIVE | 1005 | 1003 | 2023-01-04 14:13:36.980799 | 2023-01-04 18:32:08.217005 | sa128_obv4_3 | xx.xx.xx.xx | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | | 1007 | 1004 | ACTIVE | 1005 | 1004 | 2023-01-04 23:50:57.989966 | 2023-01-04 23:50:57.989966 | sa128_obv4_1 | xx.xx.xx.xx | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | | 1008 | 1004 | ACTIVE | 1005 | 1004 | 2023-01-04 23:50:57.995273 | 2023-01-04 23:50:57.995273 | sa128_obv4_2 | xx.xx.xx.xx | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | | 1009 | 1004 | ACTIVE | 1005 | 1004 | 2023-01-04 23:50:57.997360 | 2023-01-04 23:50:57.997360 | sa128_obv4_3 | xx.xx.xx.xx | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+-------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ 6 rows in setQuery the log streams of the
mq_t1tenant. In this example, the tenant has two resource units and one primary zone. Therefore, the number of log streams is 2.obclient> SELECT * FROM oceanbase.CDB_OB_LS WHERE tenant_id = 1004; +-----------+-------+--------+----------------------------------------+---------------+-------------+---------------------+----------+---------------------+---------------------+ | TENANT_ID | LS_ID | STATUS | PRIMARY_ZONE | UNIT_GROUP_ID | LS_GROUP_ID | CREATE_SCN | DROP_SCN | SYNC_SCN | READABLE_SCN | +-----------+-------+--------+----------------------------------------+---------------+-------------+---------------------+----------+---------------------+---------------------+ | 1004 | 1 | NORMAL | sa128_obv4_1;sa128_obv4_2,sa128_obv4_3 | 0 | 0 | NULL | NULL | 1672847476919847432 | 1672847476694110593 | | 1004 | 1001 | NORMAL | sa128_obv4_1;sa128_obv4_2,sa128_obv4_3 | 1003 | 1001 | 1672828353411747395 | NULL | 1672847481926946171 | 1672847481725653432 | | 1004 | 1002 | NORMAL | sa128_obv4_1;sa128_obv4_2,sa128_obv4_3 | 1004 | 1002 | 1672847466822734122 | NULL | 1672847481906918109 | 1672847481705364375 | +-----------+-------+--------+----------------------------------------+---------------+-------------+---------------------+----------+---------------------+---------------------+ 3 rows in setChange the value of the
PRIMARY_ZONEattribute from 1 to 2 for themq_t1tenant.obclient> ALTER TENANT mq_t1 PRIMARY_ZONE='sa128_obv4_1,sa128_obv4_2;sa128_obv4_3';Query the basic information about the
mq_t1tenant. In this example, the value of thePRIMARY_ZONEattribute is modified fromsa128_obv4_1tosa128_obv4_1,sa128_obv4_2.obclient> SELECT * FROM oceanbase.DBA_OB_TENANTS WHERE tenant_id = 1004; +-----------+-------------+-------------+----------------------------+----------------------------+----------------------------------------+------------------------------------------------------------------+-------------------+--------------------+--------+---------------+--------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | PREVIOUS_LOCALITY | COMPATIBILITY_MODE | STATUS | IN_RECYCLEBIN | LOCKED | +-----------+-------------+-------------+----------------------------+----------------------------+----------------------------------------+------------------------------------------------------------------+-------------------+--------------------+--------+---------------+--------+ | 1004 | mq_t1 | USER | 2023-01-04 18:32:08.212745 | 2023-01-04 23:58:49.632182 | sa128_obv4_1,sa128_obv4_2;sa128_obv4_3 | FULL{1}@sa128_obv4_1, FULL{1}@sa128_obv4_2, FULL{1}@sa128_obv4_3 | NULL | MYSQL | NORMAL | NO | NO | +-----------+-------------+-------------+----------------------------+----------------------------+----------------------------------------+------------------------------------------------------------------+-------------------+--------------------+--------+---------------+--------+ 1 row in setQuery the resource units of the
mq_t1tenant. In this example, the number of resource units remains unchanged.obclient> SELECT * FROM oceanbase.DBA_OB_UNITS WHERE tenant_id = 1004; +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+-------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 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 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+-------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1004 | 1004 | ACTIVE | 1005 | 1003 | 2023-01-04 11:48:36.582413 | 2023-01-04 18:32:08.215935 | sa128_obv4_1 | xx.xx.xx.xx | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | | 1005 | 1004 | ACTIVE | 1005 | 1003 | 2023-01-04 11:48:36.591414 | 2023-01-04 18:32:08.215935 | sa128_obv4_2 | xx.xx.xx.xx | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | | 1006 | 1004 | ACTIVE | 1005 | 1003 | 2023-01-04 14:13:36.980799 | 2023-01-04 18:32:08.217005 | sa128_obv4_3 | xx.xx.xx.xx | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | | 1007 | 1004 | ACTIVE | 1005 | 1004 | 2023-01-04 23:50:57.989966 | 2023-01-04 23:50:57.989966 | sa128_obv4_1 | xx.xx.xx.xx | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | | 1008 | 1004 | ACTIVE | 1005 | 1004 | 2023-01-04 23:50:57.995273 | 2023-01-04 23:50:57.995273 | sa128_obv4_2 | xx.xx.xx.xx | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | | 1009 | 1004 | ACTIVE | 1005 | 1004 | 2023-01-04 23:50:57.997360 | 2023-01-04 23:50:57.997360 | sa128_obv4_3 | xx.xx.xx.xx | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+-------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ 6 rows in setQuery the log streams of the
mq_t1tenant. In this example, the number of log streams changes from 2 to 4.obclient> SELECT * FROM oceanbase.CDB_OB_LS WHERE tenant_id = 1004; +-----------+-------+--------+----------------------------------------+---------------+-------------+---------------------+----------+---------------------+---------------------+ | TENANT_ID | LS_ID | STATUS | PRIMARY_ZONE | UNIT_GROUP_ID | LS_GROUP_ID | CREATE_SCN | DROP_SCN | SYNC_SCN | READABLE_SCN | +-----------+-------+--------+----------------------------------------+---------------+-------------+---------------------+----------+---------------------+---------------------+ | 1004 | 1 | NORMAL | sa128_obv4_1;sa128_obv4_2;sa128_obv4_3 | 0 | 0 | NULL | NULL | 1672847957666739465 | 1672847957458353706 | | 1004 | 1001 | NORMAL | sa128_obv4_1;sa128_obv4_2;sa128_obv4_3 | 1003 | 1001 | 1672828353411747395 | NULL | 1672847959672667216 | 1672847959571948499 | | 1004 | 1002 | NORMAL | sa128_obv4_1;sa128_obv4_2;sa128_obv4_3 | 1004 | 1002 | 1672847466822734122 | NULL | 1672847959641019952 | 1672847959540230639 | | 1004 | 1003 | NORMAL | sa128_obv4_2;sa128_obv4_1;sa128_obv4_3 | 1003 | 1001 | 1672847937481543793 | NULL | 1672847959561876069 | 1672847959461288966 | | 1004 | 1004 | NORMAL | sa128_obv4_2;sa128_obv4_1;sa128_obv4_3 | 1004 | 1002 | 1672847937561171512 | NULL | 1672847959675241289 | 1672847959574491818 | +-----------+-------+--------+----------------------------------------+---------------+-------------+---------------------+----------+---------------------+---------------------+ 5 rows in set
In the preceding example, the number of primary zones is changed from 1 to 2 for the mq_t1 tenant. Before the modification, the tenant has two resource units in each zone and the number of log streams is 2. After the modification, the number of resource units in each zone remains unchanged but the number of primary zones changes from 1 to 2. In this way, the number of log streams changes to 4. After the modification, the number of service nodes increases from 2 to 4. The tenant is scaled out.