The terms master and slave have historically been used in replication, but the terms terms primary and replica are now preferred. The old terms are used still used in parts of the documentation, and in MariaDB commands, although MariaDB 10.5 has begun the process of renaming. The documentation process is ongoing. See MDEV-18777 to follow progress on this effort. Show
Table of Contents
Getting replication working involves steps on both the master server/s and steps on the slave server/s. Setting up a Replication Slave with MariabackupIf you would like to use Mariabackup to set up a replication slave, then you might find the information at Setting up a Replication Slave with Mariabackup helpful. VersionsIn general, when replicating across different versions of MariaDB, it is best that the master is an older version than the slave. MariaDB versions are usually backward compatible, while of course older versions cannot always be forward compatible. See also Replicating from MySQL Master to MariaDB Slave. Configuring the Master
Example Enabling Replication for MariaDBAdd the following into your my.cnf file and restart the database. [mariadb] log-bin server_id=1 log-basename=master1 binlog-format=mixed The server id is a unique number for each MariaDB/MySQL server in your network. binlog-format specifies how your statements are logged. This mainly affects the size of the binary log that is sent between the Master and the Slaves. Then execute the following SQL
with the CREATE USER 'replication_user'@'%' IDENTIFIED BY 'bigs3cret'; GRANT REPLICATION SLAVE ON *.* TO 'replication_user'@'%'; Example Enabling Replication for MySQLIf you want to enable replication from MySQL to MariaDB, you can do it in almost the same way as between MariaDB servers. The main difference is that MySQL doesn't support [mysqld] log-bin server_id=1 Settings to CheckThere are a number of options that may impact or break replication. Check the following settings to avoid problems.
Configuring the Slave
Getting the Master's Binary Log Co-ordinatesNow you need prevent any changes to the data while you view the binary log position. You'll use this to tell the slave at exactly which point it should start replicating from.
SHOW MASTER STATUS; +--------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +--------------------+----------+--------------+------------------+ | master1-bin.000096 | 568 | | | +--------------------+----------+--------------+------------------+
UNLOCK TABLES; Start the Slave
CHANGE MASTER TO MASTER_HOST='master.domain.com', MASTER_USER='replication_user', MASTER_PASSWORD='bigs3cret', MASTER_PORT=3306, MASTER_LOG_FILE='master1-bin.000096', MASTER_LOG_POS=568, MASTER_CONNECT_RETRY=10; If you are starting a slave against a fresh master that was configured for replication from the start, then you don't have to specify Use Global Transaction Id (GTID)MariaDB starting with 10.0MariaDB 10.0 introduced global transaction IDs (GTIDs) for replication. It is generally recommended to use (GTIDs) from MariaDB 10.0, as this has a number of benefits. All that
is needed is to add the CHANGE MASTER TO MASTER_USE_GTID = slave_pos See Global Transaction ID for a full description.
START SLAVE;
SHOW SLAVE STATUS \G
Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicating from MySQL Master to MariaDB Slave
See Also
|