Skip to content

Commit 6110a44

Browse files
authored
Merge pull request #123187 from danvalero/patch-2
Fixed Formatting issues to How to configure Azure Database for MySQL - Flexible Server data-in replication
2 parents f5bd535 + cee73d9 commit 6110a44

File tree

1 file changed

+59
-57
lines changed

1 file changed

+59
-57
lines changed

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

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -80,110 +80,112 @@ The following steps prepare and configure the MySQL server hosted on-premises, i
8080

8181
1. After the server is restarted, verify that binary logging is enabled by running the same query as before:
8282

83-
```sql
84-
SHOW VARIABLES LIKE 'log_bin';
85-
```
83+
```sql
84+
SHOW VARIABLES LIKE 'log_bin';
85+
```
8686

8787
#### [GTID based replication](#tab/shell)
8888

8989
The Master server needs to be started with GTID mode enabled by setting the gtid_mode variable to ON. It's also essential that the enforce_gtid_consistency variable is enabled to make sure that only the statements, which are safe for MySQL GTIDs Replication are logged.
9090
91+
```sql
9192
SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = ON;
92-
9393
SET @@GLOBAL.GTID_MODE = ON;
94-
94+
```
95+
9596
If the master server is another Azure Database for MySQL flexible server instance, then these server parameters can also be updated from the portal by navigating to server parameter page.
9697
9798
9899
1. Configure the source server settings.
99100
100-
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.
101102
102-
```sql
103-
SET GLOBAL lower_case_table_names = 1;
104-
```
103+
```sql
104+
SET GLOBAL lower_case_table_names = 1;
105+
```
105106
106-
5. Create a new replication role and set up permission.
107+
1. Create a new replication role and set up permission.
107108
108-
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.
109110
110-
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).
111112
112-
#### [SQL Command](#tab/command-line)
113+
#### [SQL Command](#tab/command-line)
113114
114-
**Replication with SSL**
115+
**Replication with SSL**
115116
116-
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:
117118
118-
```sql
119-
CREATE USER 'syncuser'@'%' IDENTIFIED BY 'yourpassword';
120-
GRANT REPLICATION SLAVE ON *.* TO ' syncuser'@'%' REQUIRE SSL;
121-
```
119+
```sql
120+
CREATE USER 'syncuser'@'%' IDENTIFIED BY 'yourpassword';
121+
GRANT REPLICATION SLAVE ON *.* TO ' syncuser'@'%' REQUIRE SSL;
122+
```
122123
123-
**Replication without SSL**
124+
**Replication without SSL**
124125
125-
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:
126127

127-
```sql
128-
CREATE USER 'syncuser'@'%' IDENTIFIED BY 'yourpassword';
129-
GRANT REPLICATION SLAVE ON *.* TO ' syncuser'@'%';
130-
```
128+
```sql
129+
CREATE USER 'syncuser'@'%' IDENTIFIED BY 'yourpassword';
130+
GRANT REPLICATION SLAVE ON *.* TO ' syncuser'@'%';
131+
```
131132

132-
#### [MySQL Workbench](#tab/mysql-workbench)
133+
#### [MySQL Workbench](#tab/mysql-workbench)
133134

134-
To create the replication role in MySQL Workbench, open the **Users and Privileges** panel from the **Management** panel, and then select **Add Account**.
135+
To create the replication role in MySQL Workbench, open the **Users and Privileges** panel from the **Management** panel, and then select **Add Account**.
135136

136-
:::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":::
137138

138-
Type in the username into the **Login Name** field.
139+
Type in the username into the **Login Name** field.
139140

140-
:::image type="content" source="./media/how-to-data-in-replication/sync-user.png" alt-text="Sync user":::
141+
:::image type="content" source="./media/how-to-data-in-replication/sync-user.png" alt-text="Sync user":::
141142

142-
Select the **Administrative Roles** panel and then select **Replication Slave** from the list of **Global Privileges**. Then select **Apply** to create the replication role.
143+
Select the **Administrative Roles** panel and then select **Replication Slave** from the list of **Global Privileges**. Then select **Apply** to create the replication role.
143144

144-
:::image type="content" source="./media/how-to-data-in-replication/replication-slave.png" alt-text="Replication Slave":::
145+
:::image type="content" source="./media/how-to-data-in-replication/replication-slave.png" alt-text="Replication Slave":::
145146

146147
1. Set the source server to read-only mode.
147148

148-
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 time if 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 time if necessary.
149150

150-
```sql
151-
FLUSH TABLES WITH READ LOCK;
152-
SET GLOBAL read_only = ON;
153-
```
151+
```sql
152+
FLUSH TABLES WITH READ LOCK;
153+
SET GLOBAL read_only = ON;
154+
```
154155

155156
1. Get binary log file name and offset.
156157

157158
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.
158159

159160
```sql
160-
show master status;
161+
show master status;
161162
```
162163

163-
The results should appear similar to the following. Make sure to note the binary file name for use in later steps.
164+
The results should appear similar to the following. Make sure to note the binary file name for use in later steps.
164165

165-
:::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":::
166167

167168
---
168169

169170
## Dump and restore the source server
170171

171172
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.
172173

173-
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.
174175
175-
2. Set source server to read/write mode.
176+
1. Set source server to read/write mode.
176177
177178
After the database has been dumped, change the source MySQL server back to read/write mode.
178179
179180
```sql
180181
SET GLOBAL read_only = OFF;
181182
UNLOCK TABLES;
182183
```
183-
[!NOTE]
184-
> 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
185184
186-
3. Restore dump file to new server.
185+
>[!NOTE]
186+
> Before the server is set back to read/write mode, you can retrieve the GTID information using global variable GTID_EXECUTED. This will be used at the later stage to set GTID on the replica server.
187+
188+
1. Restore dump file to new server.
187189
188190
Restore the dump file to the server created in Azure Database for MySQL flexible server. Refer to [Dump & Restore](../concepts-migrate-dump-restore.md) for how to restore 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 instance from the virtual machine.
189191
@@ -194,9 +196,9 @@ The results should appear similar to the following. Make sure to note the binary
194196
195197
1. Skip the step if using bin-log position-based replication
196198
197-
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.
198200
199-
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:
200202
201203
```azurecli-interactive
202204
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>
@@ -215,7 +217,7 @@ For more details refer [GTID Reset](/cli/azure/mysql/flexible-server/gtid).
215217

216218
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.
217219

218-
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.
219221

220222
```sql
221223
CALL mysql.az_replication_change_master('<master_host>', '<master_user>', '<master_password>', <master_port>, '<master_log_file>', <master_log_pos>, '<master_ssl_ca>');
@@ -225,13 +227,13 @@ To link two servers and start replication, login to the target replica server in
225227
CALL mysql.az_replication_change_master_with_gtid('<master_host>', '<master_user>', '<master_password>', <master_port>,'<master_ssl_ca>');
226228
```
227229

228-
- master_host: hostname of the source server
229-
- master_user: username for the source server
230-
- master_password: password for the source server
231-
- master_port: port number on which source server is listening for connections. (3306 is the default port on which MySQL is listening)
232-
- master_log_file: binary log file name from running `show master status`
233-
- master_log_pos: binary log position from running `show master status`
234-
- 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.
235237
236238
It's recommended to pass this parameter in as a variable. For more information, visit the following examples.
237239

@@ -287,9 +289,9 @@ To link two servers and start replication, login to the target replica server in
287289
show slave status;
288290
```
289291
290-
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.
291293
292-
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.
293295

294296
## Other useful stored procedures for Data-in replication operations
295297

0 commit comments

Comments
 (0)