Skip to content

Commit 1d4d512

Browse files
authored
Update how-to-data-in-replication.md
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"
1 parent 5306a57 commit 1d4d512

File tree

1 file changed

+54
-53
lines changed

1 file changed

+54
-53
lines changed

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

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ 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

@@ -98,80 +98,80 @@ The following steps prepare and configure the MySQL server hosted on-premises, i
9898
9999
1. Configure the source server settings.
100100
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.
102102
103-
```sql
104-
SET GLOBAL lower_case_table_names = 1;
105-
```
103+
```sql
104+
SET GLOBAL lower_case_table_names = 1;
105+
```
106106
107-
5. Create a new replication role and set up permission.
107+
1. Create a new replication role and set up permission.
108108
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.
110110
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).
112112
113-
#### [SQL Command](#tab/command-line)
113+
#### [SQL Command](#tab/command-line)
114114
115-
**Replication with SSL**
115+
**Replication with SSL**
116116
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:
118118
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+
```
123123
124-
**Replication without SSL**
124+
**Replication without SSL**
125125
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:
127127

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+
```
132132

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

135-
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**.
136136

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":::
138138

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

141-
:::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":::
142142

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.
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.
144144

145-
:::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":::
146146

147147
1. Set the source server to read-only mode.
148148

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.
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.
150150

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+
```
155155

156156
1. Get binary log file name and offset.
157157

158158
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.
159159

160160
```sql
161-
show master status;
161+
show master status;
162162
```
163163

164-
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.
165165

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":::
167167

168168
---
169169

170170
## Dump and restore the source server
171171

172172
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.
173173

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.
175175
176176
2. Set source server to read/write mode.
177177
@@ -181,8 +181,9 @@ The results should appear similar to the following. Make sure to note the binary
181181
SET GLOBAL read_only = OFF;
182182
UNLOCK TABLES;
183183
```
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
186187
187188
3. Restore dump file to new server.
188189
@@ -195,9 +196,9 @@ The results should appear similar to the following. Make sure to note the binary
195196
196197
1. Skip the step if using bin-log position-based replication
197198
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.
199200
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:
201202
202203
```azurecli-interactive
203204
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).
216217

217218
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.
218219

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.
220221

221222
```sql
222223
CALL mysql.az_replication_change_master('<master_host>', '<master_user>', '<master_password>', <master_port>, '<master_log_file>', <master_log_pos>, '<master_ssl_ca>');
@@ -226,13 +227,13 @@ To link two servers and start replication, login to the target replica server in
226227
CALL mysql.az_replication_change_master_with_gtid('<master_host>', '<master_user>', '<master_password>', <master_port>,'<master_ssl_ca>');
227228
```
228229

229-
- master_host: hostname of the source server
230-
- master_user: username for the source server
231-
- master_password: password for the source server
232-
- 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.
236237
237238
It's recommended to pass this parameter in as a variable. For more information, visit the following examples.
238239

@@ -288,9 +289,9 @@ To link two servers and start replication, login to the target replica server in
288289
show slave status;
289290
```
290291
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.
292293
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.
294295

295296
## Other useful stored procedures for Data-in replication operations
296297

0 commit comments

Comments
 (0)