Purpose
You can use this statement to manually add a replica for a log stream.
Limitations and considerations
The target OBServer node has an available unit that does not contain replicas of the log stream.
You can add replicas for log streams of all tenants in the
systenant but add replicas for log streams of only the current tenant in a user tenant.This statement adds only one replica at a time. To add multiple replicas, you must execute this statement multiple times.
For the same log stream of a tenant, except for replica migration tasks that can be executed in parallel, other disaster recovery tasks (including adding replicas, deleting replicas, converting replica types, and modifying the quorum size of the log stream) can only be executed one at a time.
Note
You can query ongoing replica tasks from the
CDB_OB_LS_REPLICA_TASKSview in thesystenant or from theDBA_OB_LS_REPLICA_TASKSview in a user tenant.
Required privileges
To execute this statement, you must have the ALTER SYSTEM privilege. For more information about privileges in OceanBase Database, see Privilege types in MySQL mode and Privilege types 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 for which you want to add the replica. |
| svr_ip:svr_port | The IP address and port number of the OBServer node where you want to add the replica, for example, xxx.xx.xxx.001:2882. |
| replica_type | The type of the replica that you want to add. The following types of replicas are supported (case-insensitive):
NoteA full-featured replica can be elected as the leader, whereas a read-only replica cannot. |
| data_source | Optional. The data source of the replica that you want to add, in the svr_ip:svr_port format, for example, xxx.xx.xxx.002:2882. If this parameter is not explicitly specified, the system automatically selects an available data source.
NoticeIf the specified data source is unavailable, the system will return an error. |
| paxos_replica_num | Optional. The number of Paxos members for electing the leader for the log stream. If this parameter is not specified, the default value is used. A log stream supports a maximum of seven full-featured replicas.
NoticeThe value of the
|
| tenant_name | Optional. The name of the target tenant. If this parameter is not specified, the name of the current tenant is used.
NoticeYou can specify another tenant in the |
Examples
Execute the following statement in the sys tenant to add a replica for a log stream in 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 information about how to add a replica, see Add replicas.
References
- For information about how to drop a replica, see REMOVE REPLICA.
- For information about how to modify the type of a replica, see MODIFY REPLICA.
- For information about how to migrate a replica, see MIGRATE REPLICA.
- For information about how to modify the
PAXOS_REPLICA_NUMparameter for a replica, see MODIFY PAXOS_REPLICA_NUM. - For information about how to cancel a replica task, see CANCEL REPLICA TASK.