Purpose
You can use this statement to perform various operations, such as moving, copying, and deleting replicas, converting replica types, and switching the roles of replicas.
This statement can be executed only in the sys tenant.
Syntax
alter_system_replica_stmt:
ALTER SYSTEM replica_action;
replica_action:
SWITCH REPLICA {LEADER | FOLLOWER}
{ partition_id_desc SERVER [=] 'ip:port'
| SERVER [=] 'ip:port' [tenant_name]
| ZONE [=] 'zone' [tenant_name]
}
| DROP REPLICA partition_id_desc SERVER [=] 'ip:port'
[ZONE [=] 'zone'] [FORCE]
| {MOVE | COPY} REPLICA partition_id_desc
SOURCE [=] 'ip:port' DESTINATION [=] 'ip:port'
| REPORT REPLICA partition_id_desc
{ZONE [=] 'zone' | SERVER [=] 'ip:port'}
| {ALTER | CHANGE | MODIFY} REPLICA
partition_id_desc SERVER [=] 'ip:port'
[SET] REPLICA_TYPE = replica_type
partition_id_desc
PARTITION_ID [=] 'partition_id%partition_cnt@table_id'
partition_id | partition_cnt | table_id | task_id:
INT_VALUE
tenant_name_list:
tenant_name [, tenant_name ...]
tenant_name:
TENANT [=] tenant
replica_type:
{Full | F}
| {ReadOnly | R}
| {LogOnly | L}
| {EncryptVote | E}
Parameters
| Parameter | Description |
|---|---|
| SWITCH REPLICA | Reelects a leader. |
| DROP REPLICA | Drops a replica from a specified OBServer node. To drop replicas on the specified OBServer node, you must specify partition_id_desc and the URL of the OBServer node. |
| {MOVE | COPY} REPLICA | Moves or copies a replica. You must specify the source OBServer node, destination OBServer node, and partition_id_desc. |
| REPORT REPLICA | Forcibly makes an OBServer node or all OBServer nodes in a zone perform replica reporting. |
| {ALTER | CHANGE | MODIFY} REPLICA | Modifies replica attributes. You can modify the type of a specified replica. Supported replica types are Full, ReadOnly, LogOnly, and EncryptVote. The value of replica_type can be the full name of the four replica types or their initial letter (F, R, L, or E), which are case-insensitive. |
Examples
Move the replica whose partition ID is
0%0@1100611139403777fromxxx.xx.xx.xx1toxxx.xx.xx.xx2.obclient> ALTER SYSTEM MOVE REPLICA PARTITION_ID '0%0@1100611139403777' SOURCE 'xxx.xx.xx.xx1:xxxx' DESTINATION 'xxx.xx.xx.xx2:xxxx';Drop the replica whose partition ID is
0%0@1100611139403777.obclient> ALTER SYSTEM DROP REPLICA PARTITION_ID '0%0@1100611139403777' SERVER 'xxx.xx.xx.xx1:xxxx';Change the type of the replica whose partition ID is
0%0@1100611139403777to LogOnly.obclient> ALTER SYSTEM CHANGE REPLICA PARTITION_ID '0%0@1100611139403777' SERVER 'xxx.xx.xx.xx1:xxxx'; CHANGE REPLICA_TYPE = 'L ';Select the replica whose partition ID is
0%0@1100611139403777as the leader.obclient> ALTER SYSTEM SWITCH REPLICA LEADER PARTITION_ID '0%0@1100611139403777' SERVER 'xxx.xx.xx.xx1:xxxx';