In this document, we will discuss how to enable replication on an existing MariaDB database.
<aside>
💡 Notes
→ All of the shell commands will be performed inside of the SFTP container.
→ Whenever you see the server-id, this needs to be a unique number for each server.
→ When you see -pPW
in the mysql commands, the lack of a space is intentional!
</aside>
Edit the running service and add the following commands to the Command Override section.
--log-bin --binlog-format=mixed --server-id=1001 --log-basename=primary1 --expire-logs-days=2
Rebuild the primary database container.
From the sftp container, gain access to the mysql console with: mysql -u root -h IP-Of-Primary -p
CREATE USER 'repluser'@'%' IDENTIFIED BY 'bigs3cret';
GRANT REPLICATION SLAVE ON *.* TO 'repluser'@'%';
Enter a SQL shell once again, and run:
FLUSH TABLES WITH READ LOCK;
SET GLOBAL read_only = ON;
SHOW MASTER STATUS;