To configure multi-source replication in MariaDB, you need to run multiple instances of the slave service on the same machine.
Each instance will connect to a different master server, effectively replicating from multiple sources.
Here are the general steps:
1. Assign server IDs: Each server in your replication setup needs to have a unique ID. This can be an integer value from 1 to 2^32−1.
Set server id in `my.cnf` file: \`\`\` [mysqld] server-id=1 \`\`\`1. Setup Binary Logging on Master servers: MariaDB uses binary logs to perform the actual replication, so you need to make sure they’re turned on. Add following lines in `my.cnf` for each master server:
\`\`\` [mysqld] log-bin \`\`\`1. Configure replication user: On each master server, you will need to create a user that the slave server can use to authenticate for the replication:
\`\`\` CREATE USER ‘repl’@’%’ IDENTIFIED BY ‘password’; GRANT REPLICATION SLAVE ON . TO ‘repl’@’%’; \`\`\`1. Fetch the Binary Log Coordinates: On each master server, you will need the current position of the binary log:
\`\`\` SHOW MASTER STATUS; \`\`\` Note down the `File` and `Position`.1. Configuring the Slave Servers for Each Master: You specify the different master servers to a slave by assigning each one to a unique connection name. On slave server, add following commands for each master:
\`\`\` CHANGE MASTER ‘master-1’ TO MASTER\_HOST=‘master-1.example.com’, MASTER\_USER=‘repl’, MASTER\_PASSWORD=‘password’, MASTER_LOG_FILE=‘master1-bin.000001’, MASTER_LOG_POS=0; \`\`\`1. Start the Slave Services: To start the replication for all configured sources you need to start all slaves:
\`\`\` START ALL SLAVES; \`\`\`1. Verify the Replication Status: To make sure that everything is working correctly:
\`\`\` SHOW ALL SLAVES STATUS; \`\`\`This setup is quite complex and requires careful configuration, monitoring and management. Each slave connection will have its own threads, which need resources, and will store its own relay log files, which needs disk space.
Keep in mind, the slave will stop if it encounters any errors in the relay logs regardless of the connection from which it originates. You will have to resolve the error and manually restart the slave.