Purpose
This statement is used to manually add a replica of a log stream.
Limitations and considerations
Before adding a replica, make sure that the target server has available resources (Unit) and that there is no existing replica of the log stream on that Unit.
The sys tenant can add replicas for log streams of all tenants, while a user tenant can only add replicas for its own log streams.
This statement can only add one replica at a time. To add multiple replicas, you need to execute this statement multiple times.
For the same log stream of a tenant, only one disaster recovery task can be executed at a time, except for replica migration tasks, which can be executed in parallel.
Note
The sys tenant can check the
CDB_OB_LS_REPLICA_TASKSview to confirm if there are ongoing disaster recovery tasks. A user tenant can check theDBA_OB_LS_REPLICA_TASKSview for the same information.
Privilege requirements
The user executing this statement must have the ALTER SYSTEM privilege. For more information about OceanBase Database privileges, see Privilege classification in MySQL mode and Privilege classification in Oracle mode.
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
| Parameter | Description |
|---|---|
| ls_id | The ID of the log stream to which you want to add a replica. |
| svr_ip:svr_port | The IP address and port number of the target server to which you want to add a replica. Example: xxx.xx.xxx.001:2882. |
| replica_type | The type of the replica to be added. Currently, only the following two types are supported (case-insensitive):
NoteA |
| data_source | Optional. The data source address from which the replica will be added. The format is svr_ip:svr_port, for example, xxx.xx.xxx.002:2882. If this parameter is not explicitly specified, the system will automatically select an available data source.
NoticeIf the specified data source is unavailable, an error will be reported. |
| paxos_replica_num | Optional. The number of required members for the leader of the log stream. If this parameter is not explicitly specified, the system will use the current default value of paxos_replica_num. Additionally, the maximum number of full-featured replicas (F) for a log stream is 7.
NoticeWhen specifying the value of this parameter, the following conditions must be met:
|
| tenant_name | Optional. The name of the tenant to which the replica belongs. If not specified, the current tenant is used as the default.
NoticeThe sys tenant can specify other tenants, while a user tenant can only specify its own tenant. This statement does not support using |
Examples
Execute the following statement in the sys tenant to add a 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 removing a log stream replica, see REMOVE 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.
