Replication Overview

Replication is a feature allowing the contents of one or more servers (called primaries) to be mirrored on one or more servers (called replicas).

You can exert control over which data to replicate. All databases, one or more databases, or tables within a database can each be selectively replicated.

The main mechanism used in replication is the binary log. If binary logging is enabled, all updates to the database (data manipulation and data definition) are written into the binary log as binlog events. Replicas read the binary log from each primary in order to access the data to replicate. A relay log is created on the replica, using the same format as the binary log, and this is used to perform the replication. Old relay log files are removed when no longer needed.

A replica server keeps track of the position in the primary's binlog of the last event applied on the replica. This allows the replica server to re-connect and resume from where it left off after replication has been temporarily stopped. It also allows a replica to disconnect, be cloned and then have the new replica resume replication from the same primary.

Primaries and replicas do not need to be in constant communication with each other. It's quite possible to take servers offline or disconnect from the network, and when they come back, replication will continue where it left off.

Replication Uses

Replication is used in a number of common scenarios. Uses include:

  • Scalability. By having one or more replicas, reads can be spread over multiple servers, reducing the load on the primary. The most common scenario for a high-read, low-write environment is to have one primary, where all the writes occur, replicating to multiple replicas, which handle most of the reads.
  • Data analysis. Analyzing data may have too much of an impact on a primary server, and this can similarly be handled on a replica, while the primary continues unaffected by the extra load.
  • Backup assistance. Backups can more easily be run if a server is not actively changing the data. A common scenario is to replicate the data to a replica, which is then disconnected from the primary with the data in a stable state. Backup is then performed from this server. See Replication as a Backup Solution.
  • Distribution of data. Instead of being connected to a remote primary, it's possible to replicate the data locally and work from this data instead.

Common Replication Setups

Standard Replication

standard_replication

  • Provides infinite read scale out.
  • Provides high-availability by upgrading replica to primary.

Ring Replication

ring_replication

  • Provides read and write scaling.
  • Doesn’t handle conflicts.
  • If one primary fails, replication stops.

Star Replication

star_replication

  • Provides read and write scaling.
  • Doesn’t handle conflicts.
  • Have to use replication filters to avoid duplication of data.

Multi-Source Replication

multi_source_replication

  • Allows you to combine data from different sources.
  • Different domains executed independently in parallel on all replicas.

Cross-Version Replication Compatibility

The following table describes replication compatibility between different MariaDB Server versions. In general, the replica should always be at least equivalent in version to the primary:

Primary→MariaDB 10.3MariaDB 10.4MariaDB 10.5MariaDB 10.6MariaDB 10.11
Replica ↓
MariaDB 10.3
MariaDB 10.4
MariaDB 10.5
MariaDB 10.6
MariaDB 10.11
  • : This combination is supported.
  • : This combination is not supported.

For replication compatibility details between MariaDB and MySQL, see MariaDB versus MySQL - Compatibility: Replication Compatibility.

See Also

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.