MariaDB Master/Slave
MariaDB Master - Slave
Master (edit my.cnf)
binlog_do_db = myDatabase
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
Slave-1 (edit my.cnf)
server-id = 11
relay-log = /var/log/mysql/mysql-relay-bin.log
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = myDatabase
expire_logs_days = 10
max_binlog_size = 100M
Slave-2 (edit my.cnf)
server-id = 12
relay-log = /var/log/mysql/mysql-relay-bin.log
log_bin = /var/log/mysql/mysql-bin.logbinlog_do_db =myDatabasereplicate-do-db = myDatabase
expire_logs_days = 10
max_binlog_size = 100M
Create a user for replication
CREATE USER 'repl'@'%' IDENTIFIED BY 'repl-password';Run SQL command on each Slave
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
CHANGE MASTER TO
MASTER_HOST='Master',
MASTER_USER='repl',
MASTER_PASSWORD='repl-password',
MASTER_PORT=3306,
MASTER_CONNECT_RETRY=10;
Useful commands
- stop master;
- reset master;
- start master;
- stop slave;
- reset slave;
- start slave;
- show master status;
- show slave status;
- show binlog events;
Reference:
- show command
- Replication and Binary Log Server System Variables
- [MySQL-replication] Doble entry in mysql salve status for replicate-do-db
- MySQL Master-Master Replication
- MySQL-5.7.3- Making MySQL Slave Replication Filters Dynamic
- Replication Slave Options and Variables
Comments