MariaDB Replication Overview for SQL Server Users
Contents
MariaDB supports the following types of replication:
- Asynchronous replication.
- Semi-synchronous replication.
- Galera Cluster.
Asynchronous Replication
The original MariaDB replication system is asynchrounous master-slave replication.
A master needs to have the binary log enabled. The master logs every data change in the binary log. Every event (a binary log entry) is sent to all the slaves.
The events can be written in two formats: as an SQL statement (statement-based replication, or SBR), or as a binary representation of the change (row-based replication, or RBR). The generally slower, because the statement needs to be re-executed by the slaves. It is also less secure, because some SQL statements are not deterministic, so they could produce different results on the slaves. On the other hand row-based replication could make the binary log much bigger, and require more network traffic. For this reason, DML statements are always logged in statement format.
For more details on replication formats, see binary log formats.
The slaves have an I/O thread that receives the binary log events and writes them to the relay log. These events are then read by the SQL thread. This thread could directly apply the changes to the local databases, and this was the only option before MariaDB 10.0.5. If parallel replication is enabled, the SQL thread hands the events to the worker thread, that apply them to the databases. The latter method is recommended for performance reasons.
For more information on replication, see standard replication.