Skip to content

Commit 5ea96b0

Browse files
committed
[MySQL] New Data-out flexible server features
1 parent 69f4511 commit 5ea96b0

9 files changed

+213
-6
lines changed

articles/mysql/flexible-server/concepts-data-in-replication.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Data-in replication - Azure Database for MySQL Flexible
2+
title: Data-in replication - Azure Database for MySQL Flexible Server
33
description: Learn about using Data-in replication to synchronize from an external server into the Azure Database for MySQL Flexible service.
44
ms.service: mysql
55
ms.subservice: flexible-server
@@ -9,13 +9,13 @@ ms.author: vamehta
99
ms.date: 06/08/2021
1010
---
1111

12-
# Replicate data into Azure Database for MySQL Flexible Server
12+
# Replicate data into Azure Database for MySQL Flexible Server
1313

1414
[!INCLUDE[applies-to-mysql-flexible-server](../includes/applies-to-mysql-flexible-server.md)]
1515

1616
Data-in replication allows you to synchronize data from an external MySQL server into the Azure Database for MySQL Flexible service. The external server can be on-premises, in virtual machines, Azure Database for MySQL Single Server, or a database service hosted by other cloud providers. Data-in replication is based on the binary log (binlog) file position-based. To learn more about binlog replication, see the [MySQL binlog replication overview](https://dev.mysql.com/doc/refman/5.7/en/binlog-replication-configuration-overview.html).
1717

18-
> [!Note]
18+
> [!NOTE]
1919
> GTID-based replication is currently not supported for Azure Database for MySQL Flexible Servers.<br>
2020
> Configuring Data-in replication for zone-redundant high availability servers is not supported.
2121
@@ -40,7 +40,7 @@ It is not supported to configure Data-in replication for servers which have high
4040
> [!Tip]
4141
>If you are using HA server as a source server, MySQL native binary log (binlog) file position-based replication would fail, when failover happens on the server. If replica server supports GTID based replication, we should configure GTID based replication.
4242
43-
### Filtering
43+
### Filter
4444

4545
Modifying the parameter `replicate_wild_ignore_table` used to create replication filter for tables, is currently not supported for Azure Database for MySQL -Flexible server.
4646

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Data-out replication - Azure Database for MySQL Flexible Server
3+
description: Learn about the concepts of data-out replication out of Azure Database for MySQL - Flexible Server to another MySQL server
4+
author: VandhanaMehta
5+
ms.author: vamehta
6+
ms.reviewer: maghan
7+
ms.date: 12/29/2022
8+
ms.service: mysql
9+
ms.subservice: flexible-server
10+
ms.topic: conceptual
11+
---
12+
13+
# Replicate data from Azure Database for MySQL Flexible Server
14+
15+
[!INCLUDE[applies-to-mysql-flexible-server](../includes/applies-to-mysql-flexible-server.md)]
16+
17+
Data-out replication allows you to synchronize data out of Azure Database for MySQL - Flexible Server to another MySQL server using MySQL native replication. The MySQL server (replica) can be on-premises, in virtual machines, or a database service hosted by other cloud providers. While [Data-in replication](concepts-data-in-replication.md) helps to move data into Azure Database for MySQL - Flexible Server (replica), Data-out replication would allow you to transfer data out of Azure Database for MySQL - Flexible Server (Primary). With Data-out replication, the binary log (binlog) is made community consumable allowing the Azure Database for MySQL- Flexible server to act as a Primary server for the external replicas. To learn more about binlog replication, see the [MySQL binlog replication overview](https://dev.mysql.com/doc/refman/5.7/en/binlog-replication-configuration-overview.html).
18+
19+
> [!NOTE]
20+
> Data-out replication is not supported on Azure Database for MySQL - Flexible Server, which has Azure authentication configured.
21+
22+
The main scenarios to consider about using Data-out replication are:
23+
24+
- **Hybrid Data Synchronization:** Data-out replication can be used to keep the data synchronized between Azure Database for MySQL Flexible server and on-premises servers. This method will help to integrate seamlessly between cloud and on-premises systems in a hybrid solution. This solution can also be useful if you want to avoid vendor lock-in.
25+
26+
- **Multi-Cloud Synchronization:** For complex cloud solutions, use Data-out replication to synchronize data between Azure Database for MySQL Flexible Server and different cloud providers, including virtual machines and database services hosted in those clouds.
27+
28+
- **Migration:** Customers can do Minimal Time migration using open-source tools such as MyDumper/MyLoader with Data-out replication to migrate data out Azure MySQL Flexible server.
29+
30+
## Limitations and considerations
31+
32+
### Azure AD isn't supported
33+
34+
Data-out replication isn't supported on Azure Database for MySQL - Flexible Server, which has Azure authentication configured. Any Azure AD transaction (Azure AD user create/update) on the source server will break data-out replication.
35+
36+
> [!TIP]
37+
> Use guidance published here - MySQL :: MySQL Replication :: 2.7.3 Skipping Transactions to skip past an event or events by issuing a CHANGE MASTER TO statement to move the source's binary log position forward. Restart replication posts the action.
38+
39+
### Filter
40+
41+
You must use the replication filter to filter out Azure custom tables on the replica server. This can be achieved by setting Replicate_Wild_Ignore_Table = "mysql.\_\_%" to filter the Azure MySQL internal tables on the replica. To modify this parameter from the Azure portal, navigate to Azure Database for MySQL Flexible server and select "Server parameters" to view/edit the Replicate_Wild_Ignore_Table parameter.
42+
43+
Refer to the following general guidance on the replication filter:
44+
- MySQL 5.7 Reference Manual - 13.4.2.2 CHANGE REPLICATION FILTER Statement
45+
- MySQL 5.7 Reference Manual - 16.1.6.3 Replica Server Options and Variables
46+
- MySQL 8.0 Reference Manual - 17.2.5.4 Replication Channel Based Filters.
47+
48+
## Next steps
49+
50+
- How to configure Data-out replication
51+
- How to configure Data-in replication

articles/mysql/flexible-server/how-to-data-in-replication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.author: vamehta
99
ms.date: 06/08/2021
1010
---
1111

12-
# How to configure Azure Database for MySQL Flexible Server Data-in replication
12+
# How to configure Azure Database for MySQL Flexible Server data-in replication
1313

1414
[[!INCLUDE[applies-to-mysql-flexible-server](../includes/applies-to-mysql-flexible-server.md)]
1515

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
title: Configure Data-out replication - Azure Database for MySQL Flexible Server
3+
description: This article describes how to set up Data-in replication for Azure Database for MySQL Flexible Server.
4+
author: VandhanaMehta
5+
ms.author: vamehta
6+
ms.reviewer: maghan
7+
ms.date: 12/29/2022
8+
ms.service: mysql
9+
ms.subservice: flexible-server
10+
ms.topic: how-to
11+
---
12+
13+
# How to configure Azure Database for MySQL Flexible Server data-out replication
14+
15+
[[!INCLUDE[applies-to-mysql-flexible-server](../includes/applies-to-mysql-flexible-server.md)]
16+
17+
This article describes how to set up Data-out replication in Azure Database for MySQL Flexible Server by configuring the source and replica servers. This article assumes that you have some prior experience with MySQL servers and databases.
18+
19+
For Data-out replication, the source is always Azure Database for MySQL Flexible Server. The replica can be any external MySQL server on other cloud providers, on-premises, or virtual machines. Review the limitations and requirements of Data-out replication before performing the steps in this article.
20+
21+
> [!NOTE]
22+
> This article references the term slave, a term that Microsoft no longer uses. When the term is removed from the software, we'll remove it from this article.
23+
24+
## Create an Azure Database for MySQL Flexible Server instance to use as a source.
25+
26+
1. Create a new instance of Azure Database for MySQL Flexible Server (for example, sourceserver.mysql.database.Azure.com). Refer to [Create an Azure Database for MySQL Flexible Server server using the Azure portal for server creation](quickstart-create-server-portal.md). This server is the "source" server for Data-out replication.
27+
28+
1. Create duplicate user accounts and corresponding privileges.
29+
1. User accounts aren't replicated from the source server to the replica server. Suppose you plan on providing users with access to the replica server. In that case, you must manually create all accounts and corresponding privileges on this newly created Azure Database for MySQL Flexible Server.
30+
31+
## Configure the source MySQL server
32+
33+
The following steps prepare and configure the Azure Database for MySQL Flexible Server acting as the source.
34+
35+
1. **Networking Requirements**
36+
37+
Ensure that your network settings are established so that source and replica server can communicate seamlessly.
38+
If the source server is on public access, then ensure that firewall rules allow the replica server IP address. If the replica server is hosted on Azure, please ensure that you select the option of allowing public access from any Azure service from the networking blade in the Azure portal.
39+
If the source server is on private access, ensure that the replica server can connect to the source through Vnet peering or a VNet-to-VNet VPN gateway connection.
40+
41+
> [!NOTE]
42+
> For more information - [Networking overview - Azure Database for MySQL Flexible Server](concepts-networking.md).
43+
44+
1. **Turn on binary logging**
45+
46+
Check to see if binary logging has been enabled on the source by running the following command:
47+
SHOW VARIABLES LIKE 'log_bin';
48+
If the variable log_bin is returned with the value "ON", binary logging is enabled on your server.
49+
50+
1. **Create a new replication role and set up permission**
51+
52+
Create a user account on the configured source server with replication privileges. This can be done through SQL commands or a tool such as MySQL Workbench. Consider whether you plan on replicating with SSL, as this will need to be specified when creating the user. Refer to the MySQL documentation to understand how to add user accounts on your source server.
53+
In the following commands, the new replication role can access the source from any machine, not just the one that hosts the source itself. This is done by specifying "syncuser@'%'" in the create user command. See the MySQL documentation to learn more about setting account names.
54+
55+
**SQL Command**
56+
57+
Replication with SSL
58+
To require SSL for all user connections, use the following command to create a user:
59+
SQLCopy
60+
CREATE USER 'syncuser'@'%' IDENTIFIED BY 'yourpassword';
61+
GRANT REPLICATION SLAVE ON *.* TO ' syncuser'@'%' REQUIRE SSL;
62+
Replication without SSL
63+
If SSL isn't required for all connections, use the following command to create a user:
64+
SQLCopy
65+
CREATE USER 'syncuser'@'%' IDENTIFIED BY 'yourpassword';
66+
GRANT REPLICATION SLAVE ON *.* TO ' syncuser'@'%';
67+
68+
**MySQL Workbench**
69+
70+
To create the replication role in MySQL Workbench, open the Users and Privileges panel from the Management panel and select Add Account.
71+
72+
:::image type="content" source="media/how-to-data-out-replication/mysql-workbench-add-account.png" alt-text="Screenshot of adding an account.":::
73+
74+
Type the username into the Login Name field.
75+
76+
:::image type="content" source="media/how-to-data-out-replication/mysql-workbench-login.png" alt-text="Screenshot of logging in on MySQL Workbench.":::
77+
78+
Select the Administrative Roles panel and Replication Slave from the list of Global Privileges. Then select Apply to create the replication role.
79+
80+
:::image type="content" source="media/how-to-data-out-replication/mysql-workbench-apply.png" alt-text="Screenshot of adding permissions.":::
81+
82+
1. **Set the source server to read-only mode**
83+
84+
Before starting to dump out the database, the server needs to be placed in read-only mode. While in read-only mode, the source cannot process any write transactions. Evaluate the impact on your business and schedule the read-only window in an off-peak time if necessary.
85+
FLUSH TABLES WITH READ LOCK;
86+
SET GLOBAL read_only = ON;
87+
88+
1. **Get binary log file name and offset**
89+
90+
Run the show master status command to determine the current binary log file name and offset.
91+
show master status;
92+
93+
The results should appear similar to the following. Make sure to note the binary file name for use in later steps.
94+
95+
:::image type="content" source="media/how-to-data-out-replication/mysql-workbench-result.png" alt-text="Screenshot of results.":::
96+
97+
## Dump and restore the source server.
98+
99+
Skip this section if it's a newly created source server with no existing data to migrate to the replica. You can, at this point, unlock the tables:
100+
SET GLOBAL read_only = OFF;
101+
UNLOCK TABLES;
102+
103+
Follow the below steps if the source server has existing data to migrate to the replica.
104+
105+
1. Determine which databases and tables you want to replicate into Azure Database for MySQL Flexible Server and perform the dump from the source server.
106+
You can use mysqldump to dump databases from your primary server. For details, refer to Dump & Restore. It's unnecessary to dump the MySQL library and test library.
107+
108+
1. Set the source server to read/write mode.
109+
After dumping the database, change the source MySQL server back to read/write mode.
110+
SQLCopy
111+
SET GLOBAL read_only = OFF;
112+
UNLOCK TABLES;
113+
114+
1. Restore dump file to new server.
115+
Restore the dump file to the server created in the Azure Database for MySQL Flexible Server service. Refer to Dump & Restore for restoring a dump file to a MySQL server. If the dump file is large, upload it to a virtual machine in Azure within the same region as your replica server. Restore it to the Azure Database for MySQL Flexible Server server from the virtual machine.
116+
117+
> [!NOTE]
118+
> If you want to avoid setting the database to read only when you dump and restore, you can use mydumper/myloader.
119+
120+
## Configure the replica server to start Data-out replication.
121+
122+
1. Filtering
123+
Suppose data-out replication is being set up between Azure MySQL and an external MySQL on other cloud providers or on-premises. In that case, you must use the replication filter to filter out Azure custom tables. This can be achieved by setting Replicate_Wild_Ignore_Table = "mysql.\_\_%" to filter the Azure mysql internal tables. To modify this parameter from the Azure portal, navigate to Azure Database for MySQL Flexible server used as source and select on "Server parameters" to view/edit the "Replicate_Wild_Ignore_Table" parameter. Refer to MySQL :: MySQL 5.7 Reference Manual :: 13.4.2.2 CHANGE REPLICATION FILTER Statement for more details on modifying this server parameter.
124+
125+
1. Set the replica server by connecting to it and opening the MySQL shell on the replica server. From the prompt, run the following operation, which configures several MySQL replication settings at the same time:
126+
CHANGE THE REPLICATION SOURCE TO
127+
SOURCE_HOST='<master_host>',
128+
SOURCE_USER='<master_user>',
129+
SOURCE_PASSWORD='<master_password>',
130+
SOURCE_LOG_FILE='<master_log_file>,
131+
SOURCE_LOG_POS=<master_log_pos>
132+
133+
- master_host: hostname of the source server (example – 'source.mysql.database.Azure.com')
134+
- master_user: username for the source server (example -'syncuser'@'%')
135+
- master_password: password for the source server
136+
- master_log_file: binary log file name from running show master status
137+
- master_log_pos: binary log position from running show master status
138+
139+
> [!NOTE]
140+
> To use SSL for the connection, add the attribute SOURCE_SSL=1 to the command. For more information about using SSL in replication context, please refer - https://dev.mysql.com/doc/refman/8.0/en/change-replication-source-to.html
141+
142+
1. Activate the replica server using the following command.
143+
START REPLICA;
144+
At this point, the replica instance will begin replicating any changes made to the source server database. You can test this by creating a sample table on your source database and checking whether it gets replicated successfully.
145+
146+
1. Check replication status.
147+
Call the show slave status\G command on the replica server to view the replication status.
148+
Show slave status;
149+
If the state of Slave_IO_Running and Slave_SQL_Running are "yes" and the value of Seconds_Behind_Master is "0", replication is working well. Seconds_Behind_Master indicates how late the replica is. If the value isn't "0", it means that the replica is processing updates.
150+
151+
If the replica server is hosted in an Azure VM, set "Allow access to Azure services" to "ON" on the source to allow the source and replica servers to communicate. This setting can be changed from the Connection security options. For more information, see Manage firewall rules using the portal.
152+
153+
If you used mydumper/myloader to dump the database, you could get the master_log_file and master_log_pos from the /backup/metadata file.
154+
155+
Next steps
156+
Learn more about Data-out replication (hyperlinked to data-out concepts page) for Azure Database for MySQL Flexible Server.
64.2 KB
Loading
84.1 KB
Loading
65.4 KB
Loading
4.43 KB
Loading

articles/mysql/flexible-server/quickstart-create-server-portal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.custom: mvc, mode-ui
1010
ms.date: 06/13/2022
1111
---
1212

13-
# Quickstart: Use the Azure portal to create an Azure Database for MySQL flexible server
13+
# Quickstart: Use the Azure portal to create an Azure Database for MySQL Flexible Server
1414

1515
[!INCLUDE[applies-to-mysql-flexible-server](../includes/applies-to-mysql-flexible-server.md)]
1616

0 commit comments

Comments
 (0)