【Manager Handbook for Distributed AntDB-T】Node Management Related Commands (3): Failover and Switchover
failover
Command function:
When the gtmcoord/datanode master master node in the cluster has problems, you can switch the host of backup node over with this command to ensure the availability of the cluster.
In case of problems with the host, the backup machine can be upgraded to the host by the failover command to ensure the sustainability of the service. The specific functions can be viewed through the help command \h failover gtmcoord and \h failover datanode.
Note:
• Failover command allows standby machine to be upgraded to master without adding “FORCE” only if the standby machine is synchronous and operates noemally, otherwise it reports an error; if “FORCE” is added to failover command, the standby machine can be upgraded to master as long as it opertaes normally.
• The Failover command verifies the value of sync_state column by node information and selects the synchronous standby to be promoted to master. If there is no synchronous standby, use the force option, the asynchronous standby with the closest xlog location to master will be selected to be promoted to master.
• If the asynchronous standby is forced to be promoted to master by adding "FORCE" command, there may be a risk of data loss.
Command format:
FAILOVER GTMCOORD node_name [ FORCE ]
FAILOVER DATANODE node_name [ FORCE ]
Parameter Description:
node_name:
Node name, corresponding to the name column of the node table.
Command example:
-- Promote the synchronous standby machine of the gtmcoord master to the host:
FAILOVER GTMCOORD gc_1;
-- Force the normally running asynchronous standby gc_1 to be promoted to host:
FAILOVER GTMCOORD gc_1 FORCE;
-- Promote the synchronous standby machine of datanode master db1 to host:
FAILOVER DATANODE db1;
-- Force the normally running asynchronous standby machine to be promoted to host.
FAILOVER DATANODE db1 FORCE;
switchover
Command function:
The switchover is done between the master and the standby. The original standby is promoted to the master and the original host is downgraded to the standby and re-followed to the new host. The switchover detects whether the xlog position between the primary and the standby is the same, if it is, the switchover is done, if not, the switchover is not done. If you need to do a forced switch, you need to add the force keyword.
If the failover is forced to be performed by adding "FORCE" command, there may be a risk of data loss.
Command format:
Command: SWITCHOVER DATANODE
Description: datanode master, datanode slave switchover, the original master changes to slave and the original slave changes to master
Syntax:
SWITCHOVER DATANODE SLAVE datanode_name
Command: SWITCHOVER GTMCOORD
Description: gtmcoord master, gtmcoord slave switchover, the original master changes to slave and the original slave changes to master
Syntax:
SWITCHOVER GTMCOORD SLAVE gtmcoord_name
Command example:
-- datanode master db1_1 exchanges roles with slave db1_2
switchover datanode slave db1_2;
-- datanode master db1_2 with slave db1_1
switchover datanode slave db1_1 force;