Purpose
This statement is used to migrate a replica of the log stream, that is, to migrate the corresponding replica migration to a specified location.
Limitations and considerations
Replica migration can only be performed between zones.
Before you perform a replica migration, ensure that the target server has available resources in the form of units and that no replica of this log stream exists on those units.
If the current log stream already has seven follower replicas, you cannot execute the migration command.
This statement can only migrate one log stream replica at a time. To migrate multiple replicas, you need to execute the statement multiple times.
For the same log stream of a tenant, except that multiple replica migration tasks can be executed in parallel, only one disaster recovery task (including adding replicas, deleting replicas, converting replica types, and modifying the quorum size of the log stream) can be executed at a time.
Note
You can query the
CDB_OB_LS_REPLICA_TASKSview in the sys tenant to check whether any disaster recovery tasks are running. You can also query theDBA_OB_LS_REPLICA_TASKSview in a user tenant to check whether any disaster recovery tasks are running.
Privilege requirements
The user executing this statement must have the ALTER SYSTEM privilege. For more information about OceanBase AI Database privileges, see Permission classification.
Syntax
ALTER SYSTEM MIGRATE REPLICA
LS [=] ls_id
SOURCE [=] 'svr_ip:svr_port'
DESTINATION [=] 'destination_addr'
[DATA_SOURCE [=] 'data_source']
[TENANT [=] 'tenant_name'];
Parameters
Parameters |
Description |
|---|---|
| ls_id | Specifies the log stream ID of the replica to be migrated. |
| svr_ip:svr_port | Specify the IP address and port number of the server where the replica to be migrated resides. For example, xxx.xx.xxx.001:2882. |
| destination_addr | Specify the IP address and port number of the target server for the replica to be migrated. The format is svr_ip:svr_port, for example, xxx.xx.xxx.002:2882. |
| data_source | Optional. Specifies the data source address of the replica. You can select any other replica in the log stream as the data source address. Choose according to your actual business needs. The format is svr_ip:svr_port, for example, xxx.xx.xxx.001:2882. If this value is not explicitly specified, the system automatically selects an available data source.
NoteIf the specified data source is unavailable, the system reports an error. |
| tenant_name | Optional. Specifies the tenant to operate on. If you do not explicitly specify the tenant, the default tenant is the current tenant.
NoticeThe system tenant can specify other tenants, while a user tenant can only specify itself. This statement does not support using |
Examples
Execute the following command in the sys tenant to migrate the log stream (1002) replica from xxx.xxx.xxx.001:2882 to xxx.xxx.xxx.002:2882 in tenant mysql001.
ALTER SYSTEM MIGRATE REPLICA
LS = 1002
SOURCE = 'xxx.xxx.xxx.001:2882'
DESTINATION = 'xxx.xxx.xxx.002:2882'
TENANT = 'mysql001';
For more examples of migrating log stream replicas, see Replica migration.
References
- For information about manually adding log stream replicas, see ADD REPLICA.
- For information about deleting log stream replicas, see REMOVE REPLICA.
- For information about converting log stream replica types, see MODIFY REPLICA.
- For information about modifying the log stream
PAXOS_REPLICA_NUM, see MODIFY PAXOS_REPLICA_NUM. - For information about canceling a log stream replica task, see CANCEL REPLICA TASK.