Skip to main content
Common Reference

switch

Usage
switch [to host]

The switch command performs a planned failover to promote an existing replica to primary and reconfigure the current primary as a replica.

The most common reason for a switch operation is to perform maintenance on the primary.

If there is no argument the switch command selects the most caught up replica and promotes it as the primary. You can also specify a particular host, in which case switch will ensure that the chosen replica is fully up-to-date and promote it.

Switch is a complex operation.

  • First, we ensure that all transactions to the primary through SQL router or connector processes complete before initiating the switch.
  • It submits a flush transaction through the replicator to ensure that the chosen replica is fully caught up with the primary.
  • It then reconfigures the primary and replica to reverse their roles.
  • Finally, it puts the primary and replica back online.

In the event that switch does not complete, we attempt to revert to the old primary. If a switch fails, you should check the cluster using ls to ensure that things rolled back correctly.

Examples:

Switch to any up-to-date replica in the cluster. If no replica is available the operation fails:

cctrl> switch

Switch the primary to host mercury:

cctrl> switch to mercury

The switch command can also be used to switch between the Active and Passive clusters in a Composite Active/Passive topology.

In this scenario, the switch will promote the RELAY node in the remote cluster to be the primary, and revert the primary in the local cluster to be the Relay

To initiate the switch in a composite cluster, issue the command from the composite cluster, for example if you have cluster service east and west in a composite cluster called global, and east is the current Active site:

cctrl> use global
cctrl> switch