Multi source replication
Multi source replication means that one server has many masters from which it replicates. This is a new feature in the upcoming MariaDB 10.0 release.
New Syntax
You specify which master connection you want to work with by either specifying the connection name in the command or setting @@default_master_connection
to the connection you want to work with.
The connection name may include any characters and should be less than 64 characters. You should preferably keep this short as it will be used as a suffix for relay logs and master info index files.
The new syntax introduced to handle many connections are:
CHANGE MASTER ["connection_name"] ...
MASTER_POS_WAIT(....,["connection_name"])
RESET SLAVE ["connection_name"
SHOW [FULL] SLAVE ["connection_name"] STATUS
START SLAVE ["connection_name"] ...
STOP SLAVE ["connection_name"] ...
The original old-style connection is an empty string ''
.
You don't have to use this connection if you don't want to.
You create new master connections with CHANGE MASTER.
Replication variables for multi source
The new replication variable @@default_master_connection
specifies which connection will be used for commands and variables if you don't specify a connection. By default this is ''
(the default connection name).
The following replication variables are local for the connection.
(In other words, they show the value for the @@default_master_connection
connection). We are working on making all the important ones
local for the connection.
Type | Name | Description |
---|---|---|
Status | Slave_running | Shows if the slave is running |
Example:
set @@default_master_connection=''; show status like 'Slave_running'; set @@default_master_connection='other_connection'; show status like 'Slave_running';
If @@default_master_connection
contains a non existing name,
you will get a warning.
All other master related variables are global and affect all connections.
New files
The basic principle of the new files used by multi source replication is that they have the same name as the original relay log files suffixed with connection_name
. The main exception is the file that holds all connection that is named as the normal master-info-file
with a .index
suffix.
When you are using multi source, the following new files are created:
Name | Description |
---|---|
master-info-filename .index | The master_info file (normally master.info) with a .index suffix. This contains all master connections in use. |
relay-log -connection_name.xxxxx | The relay-log name with a connection_name suffix. The xxxxx is the relay log number. This contains the replication data read from the master. |
relay-log-index -connection_name | Contains the name of the active relay-log#-connection_name.xxxxx files. |
relay-log-info .connection_name | Contains the current master position for the connection. |
Limitations
- You can for now only have 64 masters.
- Each active connection will create 2 threads.
- Not all slave variables are multi source ready.
See also:
- The work in MariaDB is based on the project description at MDEV-253.
- The original code base comes from Taobao, developed by Plinux. A big thanks to them for this important feature!