This topic describes how to migrate a replica. Replica migration only involves the change of the replica location within a zone. It does not involve the change of the number of replicas or the replica type. Replica migration is applicable to scenarios such as node failure and load balancing.
Unit migration
Unit migration refers to the movement of a Unit within the same zone in a node to another node. You can use unit migration to migrate replicas of log streams of a tenant.
Optional: Adjust the maximum wait time for unit GC
After a unit migration is completed in OceanBase Database, the system automatically deletes the source server of the tenant and kills the sessions in the tenant. This may affect the user's execution of current query statements. To resolve this issue, OceanBase Database introduces a smooth GC (garbage collection) method for units. When a unit migration is completed, a count-down timer for unit GC starts. After the count-down timer starts, the system no longer accepts new connection requests. If there are any requests that are executed, the system waits until all these requests are executed before it triggers GC.
However, if there is an execution time-consuming task during a full unit GC, the system may not be able to trigger GC for a long time. To ensure a smooth GC, OceanBase Database uses the cluster-level parameter unit_gc_wait_time to control the maximum wait time for unit GC. Once this wait time is exceeded, the system automatically triggers GC. By default, the value of the parameter unit_gc_wait_time is 1 minute. You can modify this value as needed.
The specific steps to modify this parameter are as follows:
Log in to the sys tenant of the cluster as the root user.
Example:
obclient -h172.30.xxx.xxx -P2883 -uroot@sys#obdemo -pxxxx -ACheck the current value of the parameter
unit_gc_wait_time.obclient> SHOW PARAMETERS LIKE '%unit_gc_wait_time%';Modify the parameter
unit_gc_wait_time.Example:
obclient> ALTER SYSTEM SET unit_gc_wait_time = '1m';
Perform unit migration
Example: Migrate a unit with UNIT_ID = 1006 from the mq_t1 tenant to another node in the same zone.
Log in to the sys tenant of the cluster as the root user.
obclient -h172.30.xxx.xxx -P2883 -uroot@sys#obdemo -pxxxx -ASwitch to the
oceanbasedatabase.obclient(root@sys)[(none)]> use oceanbase;Query the
tenant_idof themq_t1tenant.In this example, the
tenant_idof themq_t1tenant is 1004.obclient(root@sys)[oceanbase]> SELECT TENANT_ID, TENANT_NAME, TENANT_TYPE, PRIMARY_ZONE, LOCALITY, STATUS, TENANT_ROLE FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'mq_t1';The query result is as follows:
+-----------+-------------+-------------+----------------------------+--------------------------------------------------------------------+--------+-------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | PRIMARY_ZONE | LOCALITY | STATUS | TENANT_ROLE | +-----------+-------------+-------------+----------------------------+--------------------------------------------------------------------+--------+-------------+ | 1004 | mq_t1 | USER | sa128_obv4_1;sa128_obv4_2 | FULL{1}@sa128_obv4_1, FULL{1}@sa128_obv4_2, FULL{1}@@sa128_obv4_3 | NORMAL | PRIMARY | +-----------+-------------+-------------+----------------------------+--------------------------------------------------------------------+--------+-------------+ 1 row in setQuery the unit information for the
mq_t1tenant.In this example, the unit with
UNIT_ID = 1006is located in thexx.xx.xx.19node of thesa128_obv4_3zone.obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_UNITS WHERE TENANT_ID = 1004;The 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 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 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 setQuery the server IP addresses of the OBServer nodes in the zone where the to-be-migrated unit is located.
In this example, the zone
sa128_obv4_3contains two OBServer nodes,xx.xx.xx.19andxx.xx.xx.158.obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_SERVERS;The query result is as follows:
+-------------+----------+----+--------------+----------+-----------------+--------+----------------------------+-----------+-----------------------+----------------------------+----------------------------+-------------------------------------------------------------------------------------------+ | 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
UNIT_ID = 1006in themq_t1tenant to another node in the same zone.obclient(root@sys)[oceanbase]> ALTER SYSTEM migrate unit = 1006 destination = 'xx.xx.xx.158:2882'; Query OK, 0 rows affectedQuery the unit migration status.
obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_UNIT_JOBS WHERE JOB_TYPE = 'MIGRATE_UNIT';The query result is as follows:
+--------+--------------+------------+-------------+----------+----------------------------+----------------------------+-----------+---------+----------+------------+--------------+-------------+ | 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 setIn the query result, if the value of the
JOB_STATUSfield isINPROGRESS, the migration is in progress. If the value isSUCCESS, the migration is completed.Query the unit migration results.
obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_UNITS WHERE UNIT_ID = 1006;The 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 | +---------+-----------+--------+------------------+---------------+----------------------------+----------------------------+--------------+-------------+----------+---------------------+-----------------------+----------------+----------------+---------+---------+-------------+---------------+----------+----------+-------------+ | 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 setThe query result shows that the value of the
UNIT_IDfield is changed fromxx.xx.xx.19toxx.xx.xx.158, indicating that the migration is successful.
Manually migrate a replica
If the location of a replica is inconsistent with the location of its unit, you can run the ALTER SYSTEM MIGRATE REPLICA command to migrate the replica to the specified location.
Limitations
The sys tenant can perform replica migration operations on the log streams of all tenants. A user tenant can perform replica migration operations only on the log streams of its own tenant.
For the same log stream of a tenant, only one disaster recovery task can be executed at a time, except for replica migration tasks. You can execute multiple replica migration tasks in parallel.
The sys tenant can query the
CDB_OB_LS_REPLICA_TASKSview to check whether a disaster recovery task is running. A user tenant can query theDBA_OB_LS_REPLICA_TASKSview to check whether a disaster recovery task is running.Replica migration can be performed only between zones of the same zone group.
Prerequisites
Before you perform a replica migration operation, make sure that the current user has the
ALTER SYSTEMprivilege. Otherwise, you cannot execute theALTER SYSTEM MIGRATE REPLICAstatement.Before you query a view, make sure that the current user has the
SELECTprivilege on the view. Otherwise, you cannot query the view.DBA_OB_TENANTSDBA_OB_LS/CDB_OB_LSGV$OB_UNITSDBA_OB_LS_LOCATIONS/CDB_OB_LS_LOCATIONS
Before you perform a replica migration operation, make sure that the target server has available resources, that is, units, and that no replicas of the log stream exist on the unit.
If you want to execute multiple replica migration tasks at the same time, set the value of the
replica_parallel_migration_modeparameter for the primary tenant toon. If you want to execute multiple replica migration tasks at the same time, set the value of thereplica_parallel_migration_modeparameter for the standby tenant toonorauto. For more information about thereplica_parallel_migration_modeparameter at the tenant level, see replica_parallel_migration_mode.
Procedure
Assume that there is a tenant named tenant1. You have executed the ALTER SYSTEM MIGRATE UNIT= 1003 DESTINATION = '100.xx.xx.002:5072'; command to migrate the unit with the unit_id of 1003 to the destination server 100.xx.xxx.002:5072. However, due to an exception, the system failed to complete the replica migration. You need to manually migrate the replicas to the destination server 100.xx.xxx.002:5072.
Log in to the cluster as the tenant.
Here is an example of the connection command:
obclient -h172.30.xxx.xxx -P2883 -uroot@tenant1#obdemo -pxxxx -AFor more information about how to connect to the database, see Overview of database connection methods (MySQL mode) and Overview of database connection methods (Oracle mode).
Obtain the tenant ID of the tenant to be operated on.
System tenant
obclient(root@sys)[oceanbase]> SELECT TENANT_NAME,TENANT_ID FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME='tenant1';User tenant
MySQL modeOracle modeExecute the following statement in MySQL mode:
obclient(root@tenant1)[oceanbase]> SELECT TENANT_NAME,TENANT_ID FROM oceanbase.DBA_OB_TENANTS;Execute the following statement in Oracle mode:
obclient(SYS@tenant1)[SYS]> SELECT TENANT_NAME,TENANT_ID FROM SYS.DBA_OB_TENANTS;The query result is as follows:
+-------------+-----------+ | TENANT_NAME | TENANT_ID | +-------------+-----------+ | tenant1 | 1002 | +-------------+-----------+ 1 row in setThe tenant ID of the tenant is
1002.For more information about the fields in the
DBA_OB_TENANTSview, see DBA_OB_TENANTS.
Query the log stream information of the tenant to be operated on.
System tenant
obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.CDB_OB_LS WHERE TENANT_ID=1002;For more information about the fields in the
CDB_OB_LSview, see CDB_OB_LS.User tenant
MySQL modeOracle modeExecute the following statement in MySQL mode:
obclient(root@tenant1)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_LS;Execute the following statement in Oracle mode:
obclient(SYS@tenant1)[SYS]> SELECT * FROM SYS.DBA_OB_LS;The query result is as follows:
+-------+--------+--------------+---------------+-------------+---------------------+----------+---------------------+---------------------+-----------+ | LS_ID | STATUS | PRIMARY_ZONE | UNIT_GROUP_ID | LS_GROUP_ID | CREATE_SCN | DROP_SCN | SYNC_SCN | READABLE_SCN | FLAG | +-------+--------+--------------+---------------+-------------+---------------------+----------+---------------------+---------------------+-----------+ | 1 | NORMAL | z1;z2 | 0 | 0 | NULL | NULL | 1712455113896017202 | 1712455113896017202 | | | 1001 | NORMAL | z1;z2 | 1001 | 1001 | 1712125812893680165 | NULL | 1712455113896017202 | 1712455113896017202 | | | 1002 | NORMAL | z1;z2 | 1002 | 1002 | 1712125812908098857 | NULL | 1712455114041323052 | 1712455113540551113 | | | 1003 | NORMAL | z1;z2 | 0 | 0 | 1712125828880850585 | NULL | 1712455113896017202 | 1712455113896017202 | DUPLICATE | +-------+--------+--------------+---------------+-------------+---------------------+----------+---------------------+---------------------+-----------+ 4 rows in setThe tenant1 has one log stream of ID 1, one of ID 1001, one of ID 1002, and one broadcast log stream of ID 1003.
For more information about the fields in the
DBA_OB_LSview, see DBA_OB_LS.
Query the unit resources of the tenant to be operated on.
System tenant
obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.GV$OB_UNITS WHERE TENANT_ID=1002;User tenant
MySQL modeOracle modeExecute the following statement in MySQL mode:
obclient(root@tenant1)[oceanbase]> SELECT * FROM oceanbase.GV$OB_UNITS;Execute the following statement in Oracle mode:
obclient(SYS@tenant1)[SYS]> SELECT * FROM SYS.GV$OB_UNITS;The query result is as follows:
+----------------+----------+---------+-----------+------+-----------+----------------+---------+---------+-------------+---------------------+---------------------+-------------+---------------+-----------------+------------------+--------+----------------------------+ | SVR_IP | SVR_PORT | UNIT_ID | TENANT_ID | ZONE | ZONE_TYPE | REGION | MAX_CPU | MIN_CPU | MEMORY_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | LOG_DISK_SIZE | LOG_DISK_IN_USE | DATA_DISK_IN_USE | STATUS | CREATE_TIME | +----------------+----------+---------+-----------+------+-----------+----------------+---------+---------+-------------+---------------------+---------------------+-------------+---------------+-----------------+------------------+--------+----------------------------+ | 100.xx.xxx.012 | 5070 | 1002 | 1002 | z1 | ReadWrite | default_region | 2 | 2 | 1073741824 | 9223372036854775807 | 9223372036854775807 | 2 | 5798205850 | 75552460 | 0 | NORMAL | 2023-11-05 22:03:30.630137 | | 100.xx.xxx.002 | 5072 | 1004 | 1002 | z2 | ReadWrite | default_region | 2 | 2 | 1073741824 | 9223372036854775807 | 9223372036854775807 | 2 | 5798205850 | 75552460 | 0 | NORMAL | 2023-11-05 22:03:30.634915 | | 100.xx.xxx.003 | 5073 | 1003 | 1002 | z2 | ReadWrite | default_region | 2 | 2 | 1073741824 | 9223372036854775807 | 9223372036854775807 | 2 | 5798205850 | 169443835 | 12582912 | NORMAL | 2023-11-05 22:03:30.633004 | | 100.xx.xxx.001 | 5071 | 1001 | 1002 | z1 | ReadWrite | default_region | 2 | 2 | 1073741824 | 9223372036854775807 | 9223372036854775807 | 2 | 5798205850 | 169443835 | 14680064 | NORMAL | 2023-11-05 22:03:30.627247 | | 100.xx.xxx.004 | 5074 | 1006 | 1002 | z3 | ReadWrite | default_region | 2 | 2 | 1073741824 | 9223372036854775807 | 9223372036854775807 | 2 | 5798205850 | 151021679 | 0 | NORMAL | 2023-11-05 22:03:30.638615 | | 100.xx.xxx.005 | 5075 | 1005 | 1002 | z3 | ReadWrite | default_region | 2 | 2 | 1073741824 | 9223372036854775807 | 9223372036854775807 | 2 | 5798205850 | 0 | 0 | NORMAL | 2023-11-05 22:03:30.636885 | +----------------+----------+---------+-----------+------+-----------+----------------+---------+---------+-------------+---------------------+---------------------+-------------+---------------+-----------------+------------------+--------+----------------------------+ 6 rows in setThe tenant has available unit resources on the servers
100.xx.xxx.012:5070,100.xx.xxx.002:5072,100.xx.xxx.003:5073,100.xx.xxx.001:5071,100.xx.xxx.004:5074, and100.xx.xxx.005:5075. The unit withunit_idof1003is located on the server100.xx.xxx.003:5073.For more information about the fields in the
GV$OB_UNITSview, see GV$OB_UNITS.
Based on the log stream information of the tenant obtained in the previous step, query the replica distribution of the log stream with ID 1002.
System tenant
obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.CDB_OB_LS_LOCATIONS WHERE LS_ID=1002 AND TENANT_ID=1002;For more information about the fields in the
CDB_OB_LS_LOCATIONSview, see CDB_OB_LS_LOCATIONS.User tenant
MySQL modeOracle modeExecute the following statement in MySQL mode:
obclient(root@tenant1)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_LS_LOCATIONS WHERE LS_ID=1002;Execute the following statement in Oracle mode:
obclient(SYS@tenant1)[SYS]> SELECT * FROM SYS.DBA_OB_LS_LOCATIONS WHERE LS_ID=1002;The query result is as follows:
+----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+-------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+ | CREATE_TIME | MODIFY_TIME | LS_ID | SVR_IP | SVR_PORT | SQL_PORT | ZONE | ROLE | MEMBER_LIST | PAXOS_REPLICA_NUMBER | REPLICA_TYPE | LEARNER_LIST | REBUILD | +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+-------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+ | 2023-11-05 23:52:15.716363 | 2023-11-05 23:52:24.212243 | 1002 | 100.xx.xxx.003 | 5073 | 5107 | z2 | LEADER | 100.xx.xxx.003:5073:1699199535653021,100.xx.xxx.012:5070:1,100.xx.xxx.004:5074:1699194477097063 | 3 | FULL | | FALSE | | 2023-11-05 22:05:20.420160 | 2023-11-05 23:52:24.807711 | 1002 | 100.xx.xxx.012 | 5070 | 5105 | z1 | FOLLOWER | NULL | NULL | FULL | | FALSE | | 2023-11-05 22:27:57.157395 | 2023-11-05 23:52:24.361105 | 1002 | 100.xx.xxx.004 | 5074 | 5109 | z3 | FOLLOWER | NULL | NULL | FULL | | FALSE | +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+-------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+ 3 rows in setBased on the query results, you need to migrate the replica on
100.xx.xxx.003:5073to another server. The replica is onz2. Based on the unit information obtained in the previous query, find an available unit in the same zone and migrate the replica to100.xx.xxx.002:5072.
Execute the replica migration command.
The statement is as follows:
ALTER SYSTEM MIGRATE REPLICA LS [=] ls_id SOURCE [=] 'svr_ip:svr_port' DESTINATION [=] 'destination_ip:destination_port' [DATA_SOURCE [=] 'data_source'] [TENANT [=] 'tenant_name']Statement description:
ls_id: specifies the log stream ID of the replica to be migrated.svr_ip:svr_port: specifies the IP address and port number of the server where the replica to be migrated is located. Example:100.xx.xxx.003:5073.destination_ip:destination_port: specifies the IP address and port number of the target server for the replica to be migrated. Example:100.xx.xxx.002:5072.data_source: specifies the data source address of the replica. You can select any replica in the log stream as the data source address. Choose an appropriate data source based on your business requirements. Example:100.xx.xxx.004:5074.If the specified data source is unavailable, an error is returned. If you do not explicitly specify this parameter, the system automatically selects an available data source.
tenant_name: specifies the tenant for which the operation is to be performed. The system tenant can specify other tenants, while a user tenant can only specify itself. If you do not explicitly specify the tenant, the default tenant is the current tenant. This statement does not support specifying all tenants, user tenants, or all Meta tenants usingall,all_user, orall_meta.This statement can migrate only one log stream replica at a time. To migrate multiple replicas, you need to execute this statement multiple times.
Here is an example:
obclient> ALTER SYSTEM MIGRATE REPLICA LS = 1002 SOURCE='100.xx.xxx.003:5073' DESTINATION = '100.xx.xxx.002:5072'After the execution is successful, query the replica distribution of the log stream again.
System tenant
obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.CDB_OB_LS_LOCATIONS WHERE LS_ID=1002 AND TENANT_ID=1002;User tenant
MySQL modeOracle modeExecute the following statement in MySQL mode:
obclient(root@tenant1)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_LS_LOCATIONS WHERE LS_ID=1002;Execute the following statement in Oracle mode:
obclient(SYS@tenant1)[SYS]> SELECT * FROM SYS.DBA_OB_LS_LOCATIONS WHERE LS_ID=1002;The query result is as follows:
+----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+-------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+ | CREATE_TIME | MODIFY_TIME | LS_ID | SVR_IP | SVR_PORT | SQL_PORT | ZONE | ROLE | MEMBER_LIST | PAXOS_REPLICA_NUMBER | REPLICA_TYPE | LEARNER_LIST | REBUILD | +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+-------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+ | 2023-11-06 00:05:39.520972 | 2023-11-06 00:05:49.101503 | 1002 | 100.xx.xxx.002 | 5072 | 5106 | z2 | LEADER | 100.xx.xxx.002:5072:1699200339454143,100.xx.xxx.012:5070:1,100.xx.xxx.004:5074:1699194477097063 | 3 | FULL | | FALSE | | 2023-11-05 22:05:20.420160 | 2023-11-06 00:05:50.037494 | 1002 | 100.xx.xxx.012 | 5070 | 5105 | z1 | FOLLOWER | NULL | NULL | FULL | | FALSE | | 2023-11-05 22:27:57.157395 | 2023-11-06 00:05:49.484669 | 1002 | 100.xx.xxx.004 | 5074 | 5109 | z3 | FOLLOWER | NULL | NULL | FULL | | FALSE | +----------------------------+----------------------------+-------+----------------+----------+----------+------+----------+-------------------------------------------------------------------------------------------------+----------------------+--------------+--------------+---------+ 3 rows in setThe query result shows that the replica of log stream 1002 on
100.xx.xxx.003:5073has been migrated to100.xx.xxx.002:5072, indicating the migration is successful.
