User Tools

Site Tools


mysql:replication

MySQL - Replication

Master

my.cnf
log-bin = /var/log/mysql/mysql-bin.log
binlog-do-db=exampledb
server-id=1 

In addition, we allow remote locking tables and receiving calls from outside.

GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY '<some_password>'; (Replace <some_password> with a real password!)
FLUSH PRIVILEGES; 
SHOW MASTER STATUS;

Result

+---------------+----------+--------------+------------------+
| File          | Position | Binlog_do_db | Binlog_ignore_db |
+---------------+----------+--------------+------------------+
| mysql-bin.006 | 183      | exampledb    |                  |
+---------------+----------+--------------+------------------+
1 row in set (0.00 sec) UNLOCK TABLES;

Slave

my.cnf
server-id=2

The rest of the things will be directly in the database. Some tutorials indicate that you can also here, too.

LOAD DATA FROM MASTER;

Do this if there is already some data.

SLAVE STOP; 
CHANGE MASTER TO MASTER_HOST='192.168.0.100', MASTER_USER='slave_user', MASTER_PASSWORD='<some_password>', MASTER_LOG_FILE='mysql-bin.006', MASTER_LOG_POS=183;

To see what this returns:

\h CHANGE MASTER TO

Summary

MASTER_HOST - Address of the master server MASTER_USER - user MASTER_PASSWORD - password MASTER_LOG_FILE - MASTER_LOG_POS -

START SLAVE;
mysql/replication.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki