This topic describes how to switch workloads over between a primary ApsaraDB RDS for MySQL instance and its secondary RDS instance. If the primary RDS instance of your database system fails, ApsaraDB RDS automatically switches your workloads over from the primary RDS instance to the secondary RDS instance to ensure service availability. After the primary/secondary switchover is complete, the secondary RDS instance becomes the new primary RDS instance. The endpoint that is used to connect to your database system remains unchanged. Your application automatically connects to the new primary RDS instance by using the endpoint. You can also manually switch your workloads over between the primary RDS instance and the secondary RDS instance.

Prerequisites

The primary RDS instance runs one of the following RDS editions:

  • RDS High-availability Edition
  • RDS Enterprise Edition
Note Primary RDS instances that run RDS Basic Edition do not have secondary RDS instances as standbys. Therefore, these primary RDS instances do not support primary/secondary switchovers.

Background information

  • Automatic primary/secondary switchover: The automatic primary/secondary switchover feature is enabled by default. If the primary RDS instance fails, ApsaraDB RDS automatically switches your workloads over to the secondary RDS instance. For more information about the causes of primary/secondary switchovers, see Reasons for primary/secondary switchovers.
  • Manual primary/secondary switchover: You can manually switch your workloads over between the primary RDS instance and the secondary RDS instance even if the automatic primary/secondary switchover feature is enabled. You can perform manual primary/secondary switchovers for disaster recovery drills. You can also perform manual primary/secondary switchovers if you use the multi-zone deployment method and want to connect your application to the RDS instance in the zone that is close to your application.
Note Data is synchronized between the primary RDS instance and the secondary RDS instance in real time. You can access only the primary RDS instance. The secondary RDS instance runs only as a standby. You cannot access the secondary RDS instance.

For more information about how to switch workloads over between primary and secondary RDS instances that run a different database engine, see the following topics:

Impacts

  • Transient connections may occur during a primary/secondary switchover. Make sure that your application is configured to automatically reconnect to your database system.
  • After a primary/secondary switchover, the read-only RDS instances that are attached to the primary RDS instance must re-establish the connections that are used to replicate data to and synchronize incremental data from the primary RDS instance. As a result, the data on the read-only RDS instances shows latencies of a few minutes.
  • A primary/secondary switchover does not cause changes to the endpoints that are used to connect to your database system. The IP addresses that are associated with the endpoints may change. If your application uses endpoints to connect to your database system, your application can still run as expected after a primary/secondary switchover.

Perform a manual primary/secondary switchover

  1. Visit the RDS instance list, select a region above, and click the target instance ID.
  2. In the left-side navigation pane, click Service Availability.
  3. In the Availability Information section of the page that appears, click Switch Primary/Secondary Instance.
  4. Specify the time at which you want to perform a primary/secondary switchover. Then, click OK.
    Note You cannot perform specific operations during a primary/secondary switchover. For example, you cannot manage databases and accounts or change the network type. We recommend that you select Switch Within Maintenance Window.

Disable the automatic primary/secondary switchover feature for a short period of time

The automatic primary/secondary switchover feature is enabled by default. If the primary RDS instance fails, ApsaraDB RDS automatically switches your workloads over from the primary RDS instance to the secondary RDS instance. You can disable the automatic primary/secondary switchover feature in the following situations:

  • A large-scale sales promotion during which you do not want a primary/secondary switchover to affect system availability
  • An important application upgrade during which you do not want a primary/secondary switchover to cause unexpected issues
  • A major event during which you do not want a primary/secondary switchover to affect system stability
  1. Visit the RDS instance list, select a region above, and click the target instance ID.
  2. In the left-side navigation pane, click Service Availability.
  3. In the Availability Information section of the page that appears, click Configure Primary/Secondary Switchover.
    Note If you cannot find the Configure Primary/Secondary Switchover button, check whether the primary RDS instance meets all prerequisites.
  4. Select Disable Temporarily, configure the Deadline parameter, and then click OK.
    Note
    • When the date and time specified by the Deadline parameter arrives, the automatic primary/secondary switchover feature is automatically enabled.
    • If you do not configure the Deadline parameter, the automatic primary/secondary switchover is disabled for one day. You can set the Deadline parameter to 23:59:59 seven days later at most.

After you disable the automatic primary/secondary switchover feature, you can go to the Service Availability page to check the deadline after which the automatic primary/secondary switchover feature can be automatically enabled.

FAQ

  • Can I access the secondary RDS instance of my database system?

    No, you cannot access the secondary RDS instance of your database system. You can access only the primary RDS instance of your database system. The secondary RDS instance runs only as a standby. You cannot access the secondary RDS instance.

  • Do I need to manually switch my workloads over from the secondary RDS instance to the primary RDS instance after a primary/secondary switchover?

    No, you do not need to manually switch your workloads over from the secondary RDS instance to the primary RDS instance after a primary/secondary switchover. The data in the primary RDS instance is the same as the data in the secondary RDS instance. After a primary/secondary switchover, the secondary RDS instance becomes the new primary RDS instance. No additional operations are required.

Related operations

Operation Description
Switch services between a primary ApsaraDB for RDS instance and its secondary instance Switches workloads over between primary and secondary ApsaraDB RDS instances.
Enable or disable automatic primary/secondary switchovers Enables or disables the automatic primary/secondary switchover feature for an ApsaraDB RDS instance.
Query settings of automatic primary/secondary switchover Queries the settings of the automatic primary/secondary switchover feature for an ApsaraDB RDS instance.