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.log
binlog_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';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
  Run SQL command on each Slave
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:


Comments

Popular posts from this blog

Wowza 4.0.1 (Wowza Streaming Engine) Released!

WebRTC for Real-Time Communications