This topic describes how to migrate units between OBServer nodes within a single zone. After you migrate units within a zone, the locations of the units change, but the number of units and the types of units in the zone remain unchanged. This feature is applicable to OBServer node failure scenarios and load balancing scenarios.
Procedure
The following example describes how to migrate the unit with the ID of 1006 in the mq_t1 tenant to another OBServer node in the same zone.
Log on to the sys tenant of the cluster as the root user.
obclient -h172.30.xxx.xxx -P2883 -uroot@sys#obdemo -pxxxx -AAccess the database named
oceanbase.obclient>use oceanbase;Query
tenant_idof themq_t1tenant.In this example,
tenant_idof themq_t1tenant is1004.obclient> SELECT * FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'mq_t1'; +-----------+-------------+-------------+----------------------------+----------------------------+----------------------------------------+------------------------------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+ | 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 | +-----------+-------------+-------------+----------------------------+----------------------------+----------------------------------------+------------------------------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+ | 1004 | mq_t1 | USER | 2023-01-04 11:57:11.384141 | 2023-01-04 11:57:37.866707 | sa128_obv4_1;sa128_obv4_2 | FULL{1}@sa128_obv4_1, FULL{1}@sa128_obv4_2 | NULL | MYSQL | NORMAL | NO | NO | PRIMARY | NORMAL | 0 | 1684396167132057328 | 1684396167132057328 | 1684396167051160964 | 4611686018427387903 | NOARCHIVELOG | DISABLED | +-----------+-------------+-------------+----------------------------+----------------------------+----------------------------------------+------------------------------------------------------------------+-------------------+--------------------+--------+---------------+--------+-------------+-------------------+------------------+---------------------+---------------------+---------------------+---------------------+--------------+----------------------------+ 1 row in setView the unit information of the
mq_t1tenant.In this example, the resource unit with the ID of
1006is located on the node with the IP address ofxx.xx.xx.19in thesa128_obv4_3zone.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 | 1002 | 2023-01-04 11:48:36.582413 | 2023-01-04 11:57:11.387383 | sa128_obv4_1 | xx.xx.xx.47 | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | | 1005 | 1004 | ACTIVE | 1005 | 1002 | 2023-01-04 11:48:36.591414 | 2023-01-04 11:57:11.388449 | sa128_obv4_2 | xx.xx.xx.81 | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | | 1006 | 1004 | ACTIVE | 1005 | 1002 | 2023-01-04 14:13:36.980799 | 2023-01-04 14:13:36.980799 | sa128_obv4_3 | xx.xx.xx.19 | 2882 | NULL | NULL | NULL | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ 3 rows in setView the IP addresses of OBServer nodes in the zone where the resource unit to be migrated resides.
In this example, the
sa128_obv4_3zone contains two OBServer nodes with the IP addresses ofxx.xx.xx.19andxx.xx.xx.158.obclient> SELECT * FROM oceanbase.DBA_OB_SERVERS; +-------------+----------+----+--------------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+ | SVR_IP | SVR_PORT | ID | ZONE | SQL_PORT | WITH_ROOTSERVER | STATUS | START_SERVICE_TIME | STOP_TIME | BLOCK_MIGRATE_IN_TIME | CREATE_TIME | MODIFY_TIME | BUILD_VERSION | +-------------+----------+----+--------------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+ | xx.xx.xx.81 | 2882 | 6 | sa128_obv4_2 | 2881 | NO | ACTIVE | 2022-12-30 16:17:03.173519 | NULL | NULL | 2022-12-30 16:08:04.749100 | 2023-01-04 11:48:36.589270 | 4.0.0.0_101000022022120716-0d7927892ad6d830e28437af099f018b0ad9a322(Dec 7 2022 16:22:15) | | xx.xx.xx.19 | 2882 | 4 | sa128_obv4_3 | 2881 | NO | ACTIVE | 2022-12-30 16:36:35.567437 | NULL | NULL | 2022-12-30 16:08:02.755200 | 2023-01-04 14:13:36.976548 | 4.0.0.0_101000022022120716-0d7927892ad6d830e28437af099f018b0ad9a322(Dec 7 2022 16:22:15) | | xx.xx.xx.158 | 2882 | 3 | sa128_obv4_3 | 2881 | NO | ACTIVE | 2022-12-12 12:42:00.054759 | NULL | NULL | 2022-11-03 15:37:09.530894 | 2022-12-22 14:43:26.717736 | 4.0.0.0_101000022022120716-0d7927892ad6d830e28437af099f018b0ad9a322(Dec 7 2022 16:22:15) | | xx.xx.xx.43 | 2882 | 1 | sa128_obv4_1 | 2881 | NO | ACTIVE | 2022-12-12 12:25:17.555651 | NULL | NULL | 2022-11-03 15:37:08.990683 | 2022-12-12 12:25:18.553763 | 4.0.0.0_101000022022120716-0d7927892ad6d830e28437af099f018b0ad9a322(Dec 7 2022 16:22:15) | | xx.xx.xx.106 | 2882 | 2 | sa128_obv4_2 | 2881 | YES | ACTIVE | 2022-12-12 11:46:37.222980 | NULL | NULL | 2022-11-03 15:37:09.490511 | 2022-12-12 11:47:31.075335 | 4.0.0.0_101000022022120716-0d7927892ad6d830e28437af099f018b0ad9a322(Dec 7 2022 16:22:15) | | xx.xx.xx.47 | 2882 | 5 | sa128_obv4_1 | 2881 | NO | ACTIVE | 2022-12-30 16:25:45.420996 | NULL | NULL | 2022-12-30 16:08:03.928478 | 2023-01-04 11:48:36.578231 | 4.0.0.0_101000022022120716-0d7927892ad6d830e28437af099f018b0ad9a322(Dec 7 2022 16:22:15) | +-------------+----------+----+--------------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+ 6 rows in setMigrate the unit with the ID of
1006in themq_t1tenant to another OBServer node in the same zone.obclient> ALTER SYSTEM migrate unit = 1006 destination = 'xx.xx.xx.158:2882'; Query OK, 0 rows affectedView the status of the unit migration job.
obclient> SELECT * FROM oceanbase.DBA_OB_UNIT_JOBS WHERE JOB_TYPE = 'MIGRATE_UNIT'; +--------+--------------+------------+-------------+----------+----------------------------+----------------------------+-----------+---------+----------+------------+------------+-------------+ | JOB_ID | JOB_TYPE | JOB_STATUS | RESULT_CODE | PROGRESS | START_TIME | MODIFY_TIME | TENANT_ID | UNIT_ID | SQL_TEXT | EXTRA_INFO | RS_SVR_IP | RS_SVR_PORT | +--------+--------------+------------+-------------+----------+----------------------------+----------------------------+-----------+---------+----------+------------+------------+-------------+ | 4 | MIGRATE_UNIT | INPROGRESS | NULL | 0 | 2023-01-04 17:22:02.208219 | 2023-01-04 17:22:02.208219 | 1004 | 1006 | NULL | NULL | xx.xx.xx.106 | 2882 | +--------+--------------+------------+-------------+----------+----------------------------+----------------------------+-----------+---------+----------+------------+------------+-------------+ 1 row in setThe value of
JOB_STATUSin the query result indicates the job status.INPROGRESSindicates that the migration job is in progress, andSUCCESSindicates that the migration job is successful.View the information of the migrated unit.
obclient> SELECT * FROM oceanbase.DBA_OB_UNITS WHERE UNIT_ID = 1006; +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+-------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 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 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+-------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 1006 | 1004 | ACTIVE | 1005 | 1002 | 2023-01-04 14:13:36.980799 | 2023-01-04 17:22:02.210245 | sa128_obv4_3 | xx.xx.xx.158 | 2882 | xx.xx.xx.19 | 2882 | YES | 1006 | 3 | 3 | 12884901888 | 38654705664 | 30000 | 30000 | 3 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+-------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ 3 rows in set
The query result shows that the unit with the ID of 1006 is migrated from xx.xx.xx.19 to xx.xx.xx.158.