This topic describes how to manually migrate, copy, drop, and switch partition replicas.
Migrate partition replicas
You can manually migrate partition replicas as the database administrator by using the following SQL syntax:
ALTER SYSTEM MOVE REPLICA PARTITION_ID [=] partition_id%partition_count@table_id SOURCE [=] 'ip:port' DESTINATION [=] 'ip:port';
Field description:
MOVE REPLICA: specifies to migrate replicas.PARTITION_ID: the ID of the partition whose replicas are to be migrated. You can obtain values ofpartition_id,partition_count, andtable_idby querying thegv$partitionview.SOURCE: the IP address and port number of the source OBServer node hosting the replicas.DESTINATION: the IP address and port number of the destination OBServer node to which the replicas are to be migrated.
Example:
obclient> ALTER SYSTEM MOVE REPLICA PARTITION_ID = '2%2@1100611139453777' SOURCE = 'xx.xx.xx.1:2882' DESTINATION = 'xx.xx.xx.2:2882';
Query OK, 0 rows affected
After the statement is successfully executed, you can view an ongoing migration task by using the following SQL syntax:
obclient> SELECT table_id,partition_idx,start_time,action,total_macro_block,ready_macro_block/total_macro_block, usec_to_time((time_to_usec(now()) - time_to_usec(start_time)) * total_macro_block / ready_macro_block + time_to_usec(start_time)) AS estimate_time FROM __all_virtual_partition_migration_status WHERE action!= 'END';
Copy partition replicas
You can manually copy partition replicas as the database administrator by using the following SQL syntax:
ALTER SYSTEM COPY REPLICA PARTITION_ID [=] partition_id%partition_count@table_id SOURCE [=] 'ip:port' DESTINATION [=] 'ip:port';
Field description:
COPY REPLICA: specifies to copy replicas. You must specify the source OBServer, destination OBServer, and the ID of partition whose replicas are to be copied.PARTITION_ID: the ID of the partition whose replicas are to be copied. You can obtain values ofpartition_id,partition_count, andtable_idby querying thegv$partitionview.SOURCE: the IP address and port number of the source OBServer node hosting the replicas.DESTINATION:the IP address and port number of the destination OBServer node to which the replicas are to be migrated.
Example:
obclient> ALTER SYSTEM COPY REPLICA PARTITION_ID = '2%2@1100611139453777' SOURCE = 'xx.xx.xx.1:2882' DESTINATION = 'xx.xx.xx.2:2882';
Query OK, 0 rows affected
Drop partition replicas
You can manually drop partition replicas as the database administrator by using the following SQL syntax, which drops read-only replicas and replicas in the Paxos group:
obclient> ALTER SYSTEM DROP REPLICA PARTITION_ID [=] partition_id%partition_count@table_id SERVER [=] ip_port_list;
Field description:
DROP REPLICA: specifies to drop replicas. To drop replicas on a specified OBServer, you must specify the ID of the partition (partition_id) whose replicas are to be dropped, the time when the OBServer was created (create_timestamp), and the URL of the OBServer.PARTITION_ID: the ID of the partition whose replicas are to be dropped. You can obtain values ofpartition_id,partition_count, andtable_idby querying thegv$partitionview.SERVER: the server where the replicas to be dropped are located.
Example:
obclient> ALTER SYSTEM DROP REPLICA PARTITION_ID = '2%2@1100611139453777' SERVER = 'xx.xx.xx.1:2882;xx.xx.xx.2:2882';
Query OK, 0 rows affected
Force drop partition replicas
You can force drop partition replicas as the database administrator by using the following syntax, which drops read-only replicas, replicas in the Paxos group, and replicas outside the Paxos group:
obclient> ALTER SYSTEM DROP REPLICA PARTITION_ID [=] partition_id%partition_count@table_id SERVER [=] ip_port_list FORCE;
Field description:
DROP REPLICA: specifies to drop replicas. To drop replicas on a specified OBServer, you must specify the ID of the partition (partition_id) whose replicas are to be dropped, the time when the OBServer was created (create_timestamp), and the URL of the OBServer.PARTITION_ID: the ID of the partition whose replicas are to be dropped. You can obtain values ofpartition_id,partition_count, andtable_idby querying thegv$partitionview.SERVER: the server where the replicas to be dropped are located.
Example:
obclient> ALTER SYSTEM DROP REPLICA PARTITION_ID = '2%2@1100611139453777' SERVER = 'xx.xx.xx.1:2882;xx.xx.xx.2:2882' FORCE;
Query OK, 0 rows affected