环境:
centos.7.7
mysql5.7
老IP :192.168.8.61, 192.168.8.62
新IP :192.168.8.41, 192.168.8.42

1、备库停机

mysql> stop slave;
systemctl stop mysqld

2、主库停机

systemctl stop mysqld

3、修改主库备库服务器IP

起主库

systemctl start mysqld

4、主库增加新同步用户授权到新IP

grant replication slave on *.* to 'repl'@'192.168.8.42' identified by 'xxx';

5、删除老的同步用户

delete from mysql.user where user='repl' and host='192.168.8.62';

flush privileges;

show grants for 'repl'@'192.168.8.42';

6、查看主库当前的偏移量(如果使用gtid可以不用记录)

show master status \G

7、起从库

systemctl start mysqld

stop slave;
change master to master_host='192.168.8.41', master_user='repl',master_password='xxx',master_port=3306,master_auto_position=1;
start slave;
grant replication slave on *.* to 'repl'@'192.168.3.41' identified by 'xxx';
flush privileges;

8、删除老的同步用户

delete from mysql.user where user='repl' and host='192.168.8.61';

9、确认同步状态

show slave status\G