Skip to content

Commit cb6f899

Browse files
authored
Merge pull request #33151 from elemount/patch-1
Update howto-data-in-replication.md for MariaDB data-in replication
2 parents d8b8f07 + fab6786 commit cb6f899

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

articles/mariadb/howto-data-in-replication.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.date: 09/24/2018
1010

1111
# How to configure Azure Database for MariaDB Data-in Replication
1212

13-
In this article, you will learn how to set up Data-in Replication in the Azure Database for MariaDB service by configuring the master and replica servers. Data-in Replication allows you to synchronize data from a master MariaDB server running on-premises, in virtual machines, or database services hosted by other cloud providers into a replica in the Azure Database for MariaDB service.
13+
In this article, you will learn how to set up Data-in Replication in the Azure Database for MariaDB service by configuring the master and replica servers. Data-in Replication allows you to synchronize data from a master MariaDB server running on-premises, in virtual machines, or database services hosted by other cloud providers into a replica in the Azure Database for MariaDB service. We recommanded you setup the data-in replication with [Global Transaction ID](https://mariadb.com/kb/en/library/gtid/) when your master server's version is 10.2 or above.
1414

1515
This article assumes that you have at least some prior experience with MariaDB servers and databases.
1616

@@ -111,7 +111,16 @@ The following steps prepare and configure the MariaDB server hosted on-premises,
111111
The results should be like following. Make sure to note the binary file name as it will be used in later steps.
112112

113113
![Master Status Results](./media/howto-data-in-replication/masterstatus.png)
114+
115+
6. Get GTID position (Optional, needed for replication with GTID)
116+
117+
Run the function [`BINLOG_GTID_POS`](https://mariadb.com/kb/en/library/binlog_gtid_pos/) command to get the GTID position for the correspond binlog file name and offset.
118+
119+
```sql
120+
select BINLOG_GTID_POS('<binlog file name>', <binlog offset>);
121+
```
114122

123+
115124
## Dump and restore master server
116125

117126
1. Dump all databases from master server
@@ -137,17 +146,24 @@ The following steps prepare and configure the MariaDB server hosted on-premises,
137146

138147
All Data-in Replication functions are done by stored procedures. You can find all procedures at [Data-in Replication Stored Procedures](reference-data-in-stored-procedures.md). The stored procedures can be run in the MySQL shell or MySQL Workbench.
139148

140-
To link two servers and start replication, login to the target replica server in the Azure DB for MariaDB service and set the external instance as the master server. This is done by using the `mysql.az_replication_change_master` stored procedure on the Azure DB for MariaDB server.
149+
To link two servers and start replication, login to the target replica server in the Azure DB for MariaDB service and set the external instance as the master 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 DB for MariaDB server.
141150

142151
```sql
143152
CALL mysql.az_replication_change_master('<master_host>', '<master_user>', '<master_password>', 3306, '<master_log_file>', <master_log_pos>, '<master_ssl_ca>');
144153
```
154+
155+
or
156+
157+
```sql
158+
CALL mysql.az_replication_change_master_with_gtid('<master_host>', '<master_user>', '<master_password>', 3306, '<master_gtid_pos>', '<master_ssl_ca>');
159+
```
145160

146161
- master_host: hostname of the master server
147162
- master_user: username for the master server
148163
- master_password: password for the master server
149164
- master_log_file: binary log file name from running `show master status`
150165
- master_log_pos: binary log position from running `show master status`
166+
- master_gtid_pos: GTID position from running `select BINLOG_GTID_POS('<binlog file name>', <binlog offset>);`
151167
- master_ssl_ca: CA certificate’s context. If not using SSL, pass in empty string.
152168
- It is recommended to pass this parameter in as a variable. See the following examples for more information.
153169

@@ -194,6 +210,10 @@ The following steps prepare and configure the MariaDB server hosted on-premises,
194210

195211
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 is not "0", it means that the replica is processing updates.
196212

213+
4. Update correspond server variables to make data-in replication more safe (Only needed for replication without GTID)
214+
215+
Because of MariaDB native replication limitation, you need to setup [`sync_master_info`](https://mariadb.com/kb/en/library/replication-and-binary-log-system-variables/#sync_master_info) and [`sync_relay_log_info`](https://mariadb.com/kb/en/library/replication-and-binary-log-system-variables/#sync_relay_log_info) variables on replication without GTID scenario. We recommand you check your slave server's `sync_master_info` and `sync_relay_log_info` variables and change them ot `1` if you want to make sure the data-in replication is stable.
216+
197217
## Other stored procedures
198218

199219
### Stop replication

0 commit comments

Comments
 (0)