1.server-id 检查
mysql> select @@server_id;
mysql> select @@server_uuid;
2.创建复制用户
mysql> CREATE USER 'repl'@'%' IDENTIFIED BY '123';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
mysql> alter user'repl'@'%' identified with mysql_native_password by '123';
mysql> flush privileges;
新环境如下操作
--------------------------------------------------------------------------------------------------------------------------------
3.从库 CHANGE MASTER TO
CHANGE MASTER TO MASTER_HOST='10.0.0.1',MASTER_PORT=3306,MASTER_USER='repl',MASTER_PASSWORD='123',master_auto_position=1;
mysql> start slave ;
mysql> show slave status \G
4.主库 CHANGE MASTER TO
CHANGE MASTER TO MASTER_HOST='10.0.0.2',MASTER_PORT=3306,MASTER_USER='repl',MASTER_PASSWORD='123',master_auto_position=1;
mysql> start slave ;
mysql> show slave status \G