How to create and manage read replicas in Azure Database for MySQL using the Azure portal

APPLIES TO: Azure Database for MySQL - Single Server

Important

Azure Database for MySQL single server is on the retirement path. We strongly recommend that you upgrade to Azure Database for MySQL flexible server. For more information about migrating to Azure Database for MySQL flexible server, see What's happening to Azure Database for MySQL Single Server?

Note

You are viewing the new service of Azure Database for MySQL. To view the documentation for classic MySQL Database for Azure, please visit this page.

In this article, you will learn how to create and manage read replicas in the Azure Database for MySQL service using the Azure portal.

Prerequisites

Important

The read replica feature is only available for Azure Database for MySQL servers in the General Purpose or Memory Optimized pricing tiers. Ensure the source server is in one of these pricing tiers.

Create a read replica

Important

If your source server has no existing replica servers, source server might need a restart to prepare itself for replication depending upon the storage used (v1/v2). Please consider server restart and perform this operation during off-peak hours. See Source Server restart for more details.

If GTID is enabled on a primary server (gtid_mode = ON), newly created replicas will also have GTID enabled and use GTID based replication. To learn more refer to Global transaction identifier (GTID)

A read replica server can be created using the following steps:

  1. Sign into the Azure portal.

  2. Select the existing Azure Database for MySQL server that you want to use as a master. This action opens the Overview page.

  3. Select Replication from the menu, under SETTINGS.

  4. Select Add Replica.

    Azure Database for MySQL - Replication

  5. Enter a name for the replica server.

    Azure Database for MySQL - Replica name

  6. Select the location for the replica server. The default location is the same as the source server's.

    Azure Database for MySQL - Replica location

    Note

    To learn more about which regions you can create a replica in, visit the read replica concepts article.

  7. Select OK to confirm creation of the replica.

Note

Read replicas are created with the same server configuration as the master. The replica server configuration can be changed after it has been created. The replica server is always created in the same resource group and same subscription as the source server. If you want to create a replica server to a different resource group or different subscription, you can move the replica server after creation. It is recommended that the replica server's configuration should be kept at equal or greater values than the source to ensure the replica is able to keep up with the master.

Once the replica server has been created, it can be viewed from the Replication blade.

Azure Database for MySQL - List replicas

Stop replication to a replica server

Important

Stopping replication to a server is irreversible. Once replication has stopped between a source and replica, it cannot be undone. The replica server then becomes a standalone server and now supports both read and writes. This server cannot be made into a replica again.

To stop replication between a source and a replica server from the Azure portal, use the following steps:

  1. In the Azure portal, select your source Azure Database for MySQL server.

  2. Select Replication from the menu, under SETTINGS.

  3. Select the replica server you wish to stop replication for.

    Azure Database for MySQL - Stop replication select server

  4. Select Stop replication.

    Azure Database for MySQL - Stop replication

  5. Confirm you want to stop replication by clicking OK.

    Azure Database for MySQL - Stop replication confirm

Delete a replica server

To delete a read replica server from the Azure portal, use the following steps:

  1. In the Azure portal, select your source Azure Database for MySQL server.

  2. Select Replication from the menu, under SETTINGS.

  3. Select the replica server you wish to delete.

    Azure Database for MySQL - Delete replica select server

  4. Select Delete replica

    Azure Database for MySQL - Delete replica

  5. Type the name of the replica and click Delete to confirm deletion of the replica.

    Azure Database for MySQL - Delete replica confirm

Delete a source server

Important

Deleting a source server stops replication to all replica servers and deletes the source server itself. Replica servers become standalone servers that now support both read and writes.

To delete a source server from the Azure portal, use the following steps:

  1. In the Azure portal, select your source Azure Database for MySQL server.

  2. From the Overview, select Delete.

    Azure Database for MySQL - Delete master

  3. Type the name of the source server and click Delete to confirm deletion of the source server.

    Azure Database for MySQL - Delete master confirm

Monitor replication

  1. In the Azure portal, select the replica Azure Database for MySQL server you want to monitor.

  2. Under the Monitoring section of the sidebar, select Metrics:

  3. Select Replication lag in seconds from the dropdown list of available metrics.

    Select Replication lag

  4. Select the time range you wish to view. The image below selects a 30 minute time range.

    Select time range

  5. View the replication lag for the selected time range. The image below displays the last 30 minutes.

    Select time range 30 minutes

Next steps