Purpose
This statement is used to remove a replica from a log stream.
Limitations and considerations
Ensure that the log stream can still form a majority after the replica is removed, otherwise an error will be returned when executing maintenance commands.
This statement can only remove one replica at a time.
For the same log stream of a tenant, except for replica migration tasks, only one disaster recovery task (including adding a replica, removing a replica, changing the replica type, and modifying the quorum size of the log stream) can be executed at a time.
Note
For the sys tenant, you can query the
CDB_OB_LS_REPLICA_TASKSview to check whether a disaster recovery task is in progress. For a user tenant, you can query theDBA_OB_LS_REPLICA_TASKSview to check whether a disaster recovery task is in progress.
Privilege requirements
The user executing this statement must have the ALTER SYSTEM privilege. For more information about OceanBase Database privileges, see Privilege types in MySQL mode and Privilege types in Oracle mode.
Syntax
ALTER SYSTEM REMOVE REPLICA
LS [=] ls_id
SERVER [=] 'svr_ip:svr_port'
[PAXOS_REPLICA_NUM [=] paxos_replica_num]
[TENANT [=] 'tenant_name'];
Parameters
| Parameter | Description |
|---|---|
| ls_id | The ID of the log stream from which a replica is to be removed. |
| svr_ip:svr_port | The IP address and port number of the server where the replica to be removed is located. Example: xxx.xx.xxx.001:2882. |
| paxos_replica_num | Optional. The number of required members for the leader of the log stream. If this parameter is not specified, the current default value of paxos_replica_num will be used. The maximum number of F replicas for a log stream is 7.
NoticeWhen you specify this parameter, the following conditions must be met:
|
| tenant_name | Optional. The name of the tenant to operate on. If not specified, the current tenant will be used as the default.
Notice
|
Examples
Execute the following statement in the sys tenant to remove a replica from the log stream of the mysql001 tenant.
ALTER SYSTEM REMOVE REPLICA
LS = 1001
SERVER = 'xxx.xxx.xxx.001:2882'
PAXOS_REPLICA_NUM = 2
TENANT = 'mysql001';
For more examples of removing log stream replicas, see Reduce replicas.
References
- For information about manually adding a log stream replica, see ADD REPLICA.
- For information about changing the type of a log stream replica, see MODIFY REPLICA.
- For information about migrating a log stream replica, see MIGRATE REPLICA.
- For information about modifying the
PAXOS_REPLICA_NUMof a log stream, see MODIFY PAXOS_REPLICA_NUM. - For information about canceling a log stream replica task, see CANCEL REPLICA TASK.
