ApsaraDB MyBase for MySQL instances support primary/secondary switchovers and primary instance elections to ensure high availability. When a primary instance becomes unavailable, the system promotes a secondary or read-only instance to become the new primary instance. You can also manually trigger these switchovers.
Background information
- Automatic switchover: This feature is enabled by default for High-availability Edition instances. If the primary instance fails, the system automatically promotes the secondary instance to primary. For Master-replica Edition instances, if a read-only instance is configured to support switchovers and the primary instance fails, the system automatically elects that read-only instance as the new primary instance.Note For a Master-replica Edition instance, at least one read-only instance must be configured to support primary instance election.
- Manual switchover: You can initiate a manual switchover even when the automatic switchover feature is enabled. Manual switchovers can be used for disaster recovery drills or to switch to a nearer instance in a multiple availability zones deployment.
Precautions
- A transient connection interruption may occur during a switchover. Ensure your application has an automatic reconnection mechanism.
- After a switchover, read-only instances may lag by several minutes as the system rebuilds replication links and synchronizes incremental data.
Manual primary/secondary switchover
- Log on to the ApsaraDB for MyBase console.
- In the upper-left corner of the page, select the target region.
In the navigation pane on the left, click Cluster List. In the Actions column of the target dedicated cluster, click Details.
- In the navigation pane on the left, click Instances, find the target instance, and then click Details in the Actions column.
- In the navigation pane on the left, click Service Availability.
- In the Availability Information section, click Switch Primary/Secondary Instance.
- Select a switchover time and click OK.
Note During a primary/secondary switchover, many operations, such as managing databases and accounts or changing the network type, cannot be performed. We recommend selecting Switch Within Maintenance Window.
Manual primary instance election
- Log on to the ApsaraDB for MyBase console.
- In the upper-left corner of the page, select the target region.
In the navigation pane on the left, click Cluster List. In the Actions column of the target dedicated cluster, click Details.
- In the navigation pane on the left, click Instances, find the target instance, and then click Details in the Actions column.
- In the navigation pane on the left, click Service Availability.
- Hover over the target instance and click Switch Now.
Note We recommend selecting a read-only instance that has a low traffic load or has the same specifications as the primary instance for the primary instance election.
- Select a switchover time and click OK.
Note During a primary instance election, many operations, such as managing databases and accounts or changing the network type, cannot be performed. We recommend selecting Switch Within Maintenance Window.
Making an instance non-switchable
If a read-only instance has a high traffic load or has lower specifications than the primary instance, you can set it to be non-switchable. A non-switchable read-only instance is excluded from primary instance election.
- Log on to the ApsaraDB for MyBase console.
- In the upper-left corner of the page, select the target region.
In the navigation pane on the left, click Cluster List. In the Actions column of the target dedicated cluster, click Details.
- In the navigation pane on the left, click Instances, find the target instance, and then click Details in the Actions column.
- In the navigation pane on the left, click Service Availability.
- Hover over the target instance and click Set as Non-switchable.
Note After a read-only instance is set as non-switchable, it only serves read requests and does not participate in a primary instance election.
- In the dialog box that appears, click OK.
Temporarily disable automatic primary/secondary switchover
- During large-scale promotions, to prevent a switchover from affecting system availability.
- During critical application upgrades, to avoid introducing variables from a switchover.
- During major events or stability assurance periods, to prevent a switchover from impacting system stability.
- Log on to the ApsaraDB for MyBase console.
- In the upper-left corner of the page, select the target region.
- In the navigation pane on the left, choose .
- Find the target instance and click Details in the Actions column.
- In the navigation pane on the left, click Service Availability.
- In the Instance Availability section, click Configure Automatic Switchover.
- In the Configure Automatic Switchover dialog box, select Disable Temporarily and set the Deadline.
Note
- When the specified Deadline is reached, automatic primary/secondary switchovers resume.
- By default, the feature is temporarily disabled for one day. You can set the deadline to a maximum of 23:59:59 seven days later.
- Click OK.
View switchover logs
- Log on to the ApsaraDB for MyBase console.
- In the upper-left corner of the page, select the target region.
- In the navigation pane on the left, choose .
- Find the target instance and click Details in the Actions column.
- In the navigation pane on the left, click Service Availability.
- In the Primary/Secondary Switchover Logs section, adjust the query time range to view the switchover logs.
The switchover log table contains the following fields: Switch event ID, Start time, End time, and Switch reason.