To balance the resource distribution among multiple OBServers in a zone, you can adjust the resource distribution among tenants to balance the resource usage in the cluster.
This topic describes how to use SQL statements to migrate resource units.
Feature applicability
You can execute the
ALTER SYSTEM MIGRATE UNITstatement only in the sys tenant.
Syntax
ALTER SYSTEM MIGRATE UNIT [=] unit_id
DESTINATION [=] ip_port;
| Parameter | Description |
|---|---|
| unit_id | The unit ID. |
| ip_port | The address of the destination server to which the resource unit is migrated. |
Examples
View resource unit distribution.
View the distribution of resource units of the
mysql002tenant in each zone.obclient [oceanbase]> SELECT A.UNIT_CONFIG_ID,B.ZONE,B.SVR_IP,B.SVR_PORT,A.NAME,A.MAX_CPU,A.MIN_CPU,A.MEMORY_SIZE,A.LOG_DISK_SIZE,A.MAX_IOPS,A.MIN_IOPS,A.IOPS_WEIGHT FROM DBA_OB_UNIT_CONFIGS A,DBA_OB_UNITS B WHERE A.UNIT_CONFIG_ID=B.UNIT_ID AND A.NAME LIKE '%mysql002%'; +----------------+-------+----------------+----------+------------------------------+---------+---------+-------------+---------------+----------+----------+-------------+ | UNIT_CONFIG_ID | ZONE | SVR_IP | SVR_PORT | NAME | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | +----------------+-------+----------------+----------+------------------------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1007 | zone1 | 10.10.10.1 | 2882 | config_mysql002_zone2_S1_zsv | 1.5 | 1.5 | 6442450944 | 19327352832 | 15000 | 15000 | 1 | | 1008 | zone3 | 10.10.10.3 | 2882 | config_mysql002_zone3_S1_zuk | 1.5 | 1.5 | 6442450944 | 19327352832 | 15000 | 15000 | 1 | | 1009 | zone2 | 10.10.10.2 | 2882 | config_mysql002_zone1_S1_zek | 1.5 | 1.5 | 6442450944 | 19327352832 | 15000 | 15000 | 1 | +----------------+-------+----------------+----------+------------------------------+---------+---------+-------------+---------------+----------+----------+-------------+ 3 rows in setStart resource unit migration.
Migrate the resource units of the
mysql002tenant in zone 3 from10.10.10.3:2882to10.10.10.4:2882.obclient [oceanbase]> ALTER SYSTEM MIGRATE UNIT = 1008 DESTINATION = '10.10.10.4:2882'; Query OK, 0 rows affectedView the migration status.
obclient [oceanbase]> SELECT A.UNIT_CONFIG_ID,B.ZONE,B.SVR_IP,B.SVR_PORT,A.NAME,A.MAX_CPU,A.MIN_CPU,A.MEMORY_SIZE,A.LOG_DISK_SIZE,A.MAX_IOPS,A.MIN_IOPS,A.IOPS_WEIGHT FROM DBA_OB_UNIT_CONFIGS A,DBA_OB_UNITS B WHERE A.UNIT_CONFIG_ID=B.UNIT_ID AND A.NAME LIKE '%mysql002%'; +----------------+-------+----------------+----------+------------------------------+---------+---------+-------------+---------------+----------+----------+-------------+ | UNIT_CONFIG_ID | ZONE | SVR_IP | SVR_PORT | NAME | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | +----------------+-------+----------------+----------+------------------------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1007 | zone1 | 10.10.10.1 | 2882 | config_mysql002_zone2_S1_zsv | 1.5 | 1.5 | 6442450944 | 19327352832 | 15000 | 15000 | 1 | | 1008 | zone3 | 10.10.10.4 | 2882 | config_mysql002_zone3_S1_zuk | 1.5 | 1.5 | 6442450944 | 19327352832 | 15000 | 15000 | 1 | | 1009 | zone2 | 10.10.10.2 | 2882 | config_mysql002_zone1_S1_zek | 1.5 | 1.5 | 6442450944 | 19327352832 | 15000 | 15000 | 1 | +----------------+-------+----------------+----------+------------------------------+---------+---------+-------------+---------------+----------+----------+-------------+ 3 rows in set
More information
For more information about the syntax for resource unit migration, see MIGRATE UNIT.
For more information about canceling resource unit migration, see CANCEL MIGRATE UNIT.