Closed Alice52 closed 3 years ago
login master and grant
flush logs;
grant replication slave on *.* to 'backup'@'%' identified by '123456';
FLUSH PRIVILEGES;
handle legacy data and start slave sync
-- master
-- 1. frozen master data
mysql> flush tables with read lock;
-- 2. new terminal and backup data
mysqldump -h 127.0.0.1 -uroot -proot --skip-comments --databases --compact -C -q -f db1 db2 db3 >> back.sql
-- 3. obtain master bin-log postion
mysql> show master status;
-- 4. unfrozen master data
mysql> unlock tables;
-- slave
-- 1. import data from backup
$ mysql -uroot -proot <back.sql
-- 2. set connection to master with bin-log position
CHANGE MASTER TO MASTER_HOST='172.18.135.185',MASTER_PORT=3306,MASTER_USER='repl',
MASTER_PASSWORD='repl',MASTER_LOG_FILE='mysql-bin.000028',MASTER_LOG_POS=4032;
-- 3. enable slave
mysql> start slave;
set slave read only
-- set read only
SET GLOBAL READ_ONLY=1;
set global super_read_only=ON;
config mysql master-slave by docker