Primary/secondary switchovers and primary instance elections

更新时间:
复制 MD 格式

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

Note Only ApsaraDB MyBase for MySQL High-availability Edition instances support primary/secondary switchover.
  1. Log on to the ApsaraDB for MyBase console.
  2. In the upper-left corner of the page, select the target region.
  3. In the navigation pane on the left, click Cluster List. In the Actions column of the target dedicated cluster, click Details.

  4. In the navigation pane on the left, click Instances, find the target instance, and then click Details in the Actions column.
  5. In the navigation pane on the left, click Service Availability.
  6. In the Availability Information section, click Switch Primary/Secondary Instance.
  7. 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

Note Only ApsaraDB MyBase for MySQL Master-replica Edition instances support primary instance election.
  1. Log on to the ApsaraDB for MyBase console.
  2. In the upper-left corner of the page, select the target region.
  3. In the navigation pane on the left, click Cluster List. In the Actions column of the target dedicated cluster, click Details.

  4. In the navigation pane on the left, click Instances, find the target instance, and then click Details in the Actions column.
  5. In the navigation pane on the left, click Service Availability.
  6. 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.
  7. 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

Note Only ApsaraDB MyBase for MySQL Master-replica Edition instances allow you to set a read-only instance to be 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.

  1. Log on to the ApsaraDB for MyBase console.
  2. In the upper-left corner of the page, select the target region.
  3. In the navigation pane on the left, click Cluster List. In the Actions column of the target dedicated cluster, click Details.

  4. In the navigation pane on the left, click Instances, find the target instance, and then click Details in the Actions column.
  5. In the navigation pane on the left, click Service Availability.
  6. 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.
  7. In the dialog box that appears, click OK.

Temporarily disable automatic primary/secondary switchover

Note Automatic primary/secondary switchover can be temporarily disabled only for ApsaraDB MyBase for MySQL High-availability Edition instances.
Automatic primary/secondary switchover is enabled by default. If the primary instance fails, the system automatically switches to the secondary instance. You can temporarily disable this feature in the following scenarios:
  • 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.
  1. Log on to the ApsaraDB for MyBase console.
  2. In the upper-left corner of the page, select the target region.
  3. In the navigation pane on the left, choose Instances > MySQL.
  4. Find the target instance and click Details in the Actions column.
  5. In the navigation pane on the left, click Service Availability.
  6. In the Instance Availability section, click Configure Automatic Switchover.
  7. 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.
  8. Click OK.
After the configuration is complete, you can view the temporary disablement deadline on the Service Availability page.

View switchover logs

  1. Log on to the ApsaraDB for MyBase console.
  2. In the upper-left corner of the page, select the target region.
  3. In the navigation pane on the left, choose Instance List > MySQL.
  4. Find the target instance and click Details in the Actions column.
  5. In the navigation pane on the left, click Service Availability.
  6. 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.