Description
This statement is used to manually add a log stream replica.
Limitations and considerations
Before adding a replica, ensure that the target server has available resources and that no replicas of this log stream exist on those resources.
The sys tenant can add replicas to log streams of all tenants, while a user tenant can only add replicas to its own log streams.
This statement can add only one replica at a time. To add 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, changing 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 ADD REPLICA
LS [=] ls_id
SERVER [=] 'svr_ip:svr_port'
REPLICA_TYPE [=] 'replica_type'
[DATA_SOURCE [=] 'data_source']
[PAXOS_REPLICA_NUM [=] $paxos_replica_num]
[TENANT [=] '$tenant_name'];
Parameters
Parameters |
Description |
|---|---|
| ls_id | Specifies the log stream ID to which a replica is to be added. |
| svr_ip:svr_port | Specify the IP address and port of the target server to which you want to add the replica. For example, xxx.xx.xxx.001:2882. |
| replica_type | Specifies the type of replica to add. Currently, only the following two types are supported (case-insensitive):
Note
|
| data_source | Optional. The data source address of the replica to be added. Format: svr_ip:svr_port, for example, xxx.xx.xxx.002: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 returns an error. |
| paxos_replica_num | Optional. Specifies the required number of quorum members for the log stream leader. If this value is not explicitly specified, the system will use the current default value of paxos_replica_num. Also, the number of F replicas for a log stream cannot exceed 7.
NoticeTo specify a value for this parameter, the following conditions must be met:
|
| 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 add a log stream replica for the mysql001 tenant.
ALTER SYSTEM ADD REPLICA
LS = 1001
SERVER = 'xxx.xxx.xxx.001:2882'
REPLICA_TYPE = 'F'
DATA_SOURCE = 'xxx.xxx.xxx.002:2882'
PAXOS_REPLICA_NUM = 3
TENANT = 'mysql001';
For more examples of adding log stream replicas, see Add a replica.
References
- For information about deleting log stream replicas, see REMOVE REPLICA.
- For information about converting log stream replica types, see MODIFY REPLICA.
- For information about migrating log stream replicas, see MIGRATE 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.