You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix formatting that was causing the document to be hard to read and follow. and some steps were missing depending of the selected tab in section "Configure the source MySQL server"
Copy file name to clipboardExpand all lines: articles/mysql/flexible-server/how-to-data-in-replication.md
+54-53Lines changed: 54 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,9 +80,9 @@ The following steps prepare and configure the MySQL server hosted on-premises, i
80
80
81
81
1. After the server is restarted, verify that binary logging is enabled by running the same query as before:
82
82
83
-
```sql
84
-
SHOW VARIABLES LIKE 'log_bin';
85
-
```
83
+
```sql
84
+
SHOW VARIABLES LIKE 'log_bin';
85
+
```
86
86
87
87
#### [GTID based replication](#tab/shell)
88
88
@@ -98,80 +98,80 @@ The following steps prepare and configure the MySQL server hosted on-premises, i
98
98
99
99
1. Configure the source server settings.
100
100
101
-
Data-in replication requires the parameter `lower_case_table_names` to be consistent between the source and replica servers. This parameter is 1 by default in Azure Database for MySQL flexible server.
101
+
Data-in replication requires the parameter `lower_case_table_names` to be consistent between the source and replica servers. This parameter is 1 by default in Azure Database for MySQL flexible server.
102
102
103
-
```sql
104
-
SET GLOBAL lower_case_table_names = 1;
105
-
```
103
+
```sql
104
+
SET GLOBAL lower_case_table_names = 1;
105
+
```
106
106
107
-
5. Create a new replication role and set up permission.
107
+
1. Create a new replication role and set up permission.
108
108
109
-
Create a user account on the source server that is configured 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](https://dev.mysql.com/doc/refman/5.7/en/user-names.html) on your source server.
109
+
Create a user account on the source server that is configured 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](https://dev.mysql.com/doc/refman/5.7/en/user-names.html) on your source server.
110
110
111
-
In the following commands, the new replication role created can access the source from any machine, not just the machine that hosts the source itself. This is done by specifying "syncuser@'%'" in the create user command. See the MySQL documentation to learn more about [specifying account names](https://dev.mysql.com/doc/refman/5.7/en/account-names.html).
111
+
In the following commands, the new replication role created can access the source from any machine, not just the machine that hosts the source itself. This is done by specifying "syncuser@'%'" in the create user command. See the MySQL documentation to learn more about [specifying account names](https://dev.mysql.com/doc/refman/5.7/en/account-names.html).
112
112
113
-
#### [SQL Command](#tab/command-line)
113
+
#### [SQL Command](#tab/command-line)
114
114
115
-
**Replication with SSL**
115
+
**Replication with SSL**
116
116
117
-
To require SSL for all user connections, use the following command to create a user:
117
+
To require SSL for all user connections, use the following command to create a user:
118
118
119
-
```sql
120
-
CREATE USER 'syncuser'@'%' IDENTIFIED BY 'yourpassword';
121
-
GRANT REPLICATION SLAVE ON *.* TO ' syncuser'@'%' REQUIRE SSL;
122
-
```
119
+
```sql
120
+
CREATE USER 'syncuser'@'%' IDENTIFIED BY 'yourpassword';
121
+
GRANT REPLICATION SLAVE ON *.* TO ' syncuser'@'%' REQUIRE SSL;
122
+
```
123
123
124
-
**Replication without SSL**
124
+
**Replication without SSL**
125
125
126
-
If SSL isn't required for all connections, use the following command to create a user:
126
+
If SSL isn't required for all connections, use the following command to create a user:
127
127
128
-
```sql
129
-
CREATE USER 'syncuser'@'%' IDENTIFIED BY 'yourpassword';
130
-
GRANT REPLICATION SLAVE ON *.* TO ' syncuser'@'%';
131
-
```
128
+
```sql
129
+
CREATE USER 'syncuser'@'%' IDENTIFIED BY 'yourpassword';
130
+
GRANT REPLICATION SLAVE ON *.* TO ' syncuser'@'%';
131
+
```
132
132
133
-
#### [MySQL Workbench](#tab/mysql-workbench)
133
+
#### [MySQL Workbench](#tab/mysql-workbench)
134
134
135
-
To create the replication role in MySQL Workbench, open the **Users and Privileges** panel from the **Management** panel, and thenselect**Add Account**.
135
+
To create the replication role in MySQL Workbench, open the **Users and Privileges** panel from the **Management** panel, and thenselect**Add Account**.
136
136
137
-
:::image type="content" source="./media/how-to-data-in-replication/users-privileges.png" alt-text="Users and Privileges":::
137
+
:::image type="content" source="./media/how-to-data-in-replication/users-privileges.png" alt-text="Users and Privileges":::
138
138
139
-
Type in the username into the **Login Name** field.
139
+
Type in the username into the **Login Name** field.
Select the **Administrative Roles** panel and thenselect**Replication Slave** from the list of **Global Privileges**. Then select**Apply** to create the replication role.
143
+
Select the **Administrative Roles** panel and thenselect**Replication Slave** from the list of **Global Privileges**. Then select**Apply** to create the replication role.
Before starting to dump out the database, the server needs to be placed in read-only mode. While in read-only mode, the source will be unable to process any write transactions. Evaluate the impact to your business and schedule the read-only window in an off-peak timeif necessary.
149
+
Before starting to dump out the database, the server needs to be placed in read-only mode. While in read-only mode, the source will be unable to process any write transactions. Evaluate the impact to your business and schedule the read-only window in an off-peak timeif necessary.
150
150
151
-
```sql
152
-
FLUSH TABLES WITH READ LOCK;
153
-
SET GLOBAL read_only = ON;
154
-
```
151
+
```sql
152
+
FLUSH TABLES WITH READ LOCK;
153
+
SET GLOBAL read_only = ON;
154
+
```
155
155
156
156
1. Get binary log file name and offset.
157
157
158
158
Run the [`show master status`](https://dev.mysql.com/doc/refman/5.7/en/show-master-status.html) command to determine the current binary log file name and offset.
159
159
160
160
```sql
161
-
show master status;
161
+
show master status;
162
162
```
163
163
164
-
The results should appear similar to the following. Make sure to note the binary file name forusein later steps.
164
+
The results should appear similar to the following. Make sure to note the binary file name forusein later steps.
165
165
166
-
:::image type="content" source="./media/how-to-data-in-replication/master-status.png" alt-text="Master Status Results":::
166
+
:::image type="content" source="./media/how-to-data-in-replication/master-status.png" alt-text="Master Status Results":::
167
167
168
168
---
169
169
170
170
## Dump and restore the source server
171
171
172
172
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.
173
173
174
-
You can use mysqldump to dump databases from your primary server. For details, refer to [Dump & Restore](../concepts-migrate-dump-restore.md). It's unnecessary to dump the MySQL library and test library.
174
+
You can use mysqldump to dump databases from your primary server. For details, refer to [Dump & Restore](../concepts-migrate-dump-restore.md). It's unnecessary to dump the MySQL library and test library.
175
175
176
176
2. Set source server to read/write mode.
177
177
@@ -181,8 +181,9 @@ The results should appear similar to the following. Make sure to note the binary
181
181
SET GLOBAL read_only = OFF;
182
182
UNLOCK TABLES;
183
183
```
184
-
>[!NOTE]
185
-
> Before the server is set back to read/write mode, you can retrieve the GTID information using global variable GTID_EXECUTED. The same will be used at the later stage to set GTID on the replica server
184
+
185
+
>[!NOTE]
186
+
> Before the server is set back to read/write mode, you can retrieve the GTID information using global variable GTID_EXECUTED. The same will be used at the later stage to set GTID on the replica server
186
187
187
188
3. Restore dump file to new server.
188
189
@@ -195,9 +196,9 @@ The results should appear similar to the following. Make sure to note the binary
195
196
196
197
1. Skip the step if using bin-log position-based replication
197
198
198
-
2. GTID information from the dump file taken from the source is required to reset GTID history of the target (replica) server.
199
+
1. GTID information from the dump file taken from the source is required to reset GTID history of the target (replica) server.
199
200
200
-
3. Use this GTID information from the source to execute GTID reset on the replica server using the following CLI command:
201
+
1. Use this GTID information from the source to execute GTID reset on the replica server using the following CLI command:
201
202
202
203
```azurecli-interactive
203
204
az mysql flexible-server gtid reset --resource-group <resource group> --server-name <replica server name> --gtid-set <gtid set from the source server> --subscription <subscription id>
@@ -216,7 +217,7 @@ For more details refer [GTID Reset](/cli/azure/mysql/flexible-server/gtid).
216
217
217
218
All Data-in replication functions are done by stored procedures. You can find all procedures at [Data-in replication Stored Procedures](../reference-stored-procedures.md). The stored procedures can be run in the MySQL shell or MySQL Workbench.
218
219
219
-
To link two servers and start replication, login to the target replica server in the Azure Database for MySQL service and set the external instance as the source server. This is done by using the `mysql.az_replication_change_master` or `mysql.az_replication_change_master_with_gtid` stored procedure on the Azure Database for MySQL server.
220
+
To link two servers and start replication, login to the target replica server in the Azure Database for MySQL service and set the external instance as the source server. This is done by using the `mysql.az_replication_change_master` or `mysql.az_replication_change_master_with_gtid` stored procedure on the Azure Database for MySQL server.
- master_port: port number on which source server is listening for connections. (3306 is the default port on which MySQL is listening)
233
-
- master_log_file: binary log file name from running `show master status`
234
-
- master_log_pos: binary log position from running `show master status`
235
-
- master_ssl_ca: CA certificate's context. If not using SSL, pass in empty string.
230
+
- master_host: hostname of the source server
231
+
- master_user: username for the source server
232
+
- master_password: password for the source server
233
+
- master_port: port number on which source server is listening for connections. (3306 is the default port on which MySQL is listening)
234
+
- master_log_file: binary log file name from running `show master status`
235
+
- master_log_pos: binary log position from running `show master status`
236
+
- master_ssl_ca: CA certificate's context. If not using SSL, pass in empty string.
236
237
237
238
It's recommended to pass this parameter in as a variable. For more information, visit the following examples.
238
239
@@ -288,9 +289,9 @@ To link two servers and start replication, login to the target replica server in
288
289
show slave status;
289
290
```
290
291
291
-
To know the correct status of replication, refer to replication metrics - **Replica IO Status** and **Replica SQL Status** under monitoring page.
292
+
To know the correct status of replication, refer to replication metrics - **Replica IO Status** and **Replica SQL Status** under monitoring page.
292
293
293
-
If the `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.
294
+
If the `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.
294
295
295
296
## Other useful stored procedures for Data-in replication operations
0 commit comments