环境:
redhat7.5
mysql5.7
老IP :192.168.1.1, 192.168.1.2
新IP :192.168.3.3, 192.168.3.4
--备库停机
mysql> stop slave;
systemctl stop mysqld
--主库停机
systemctl stop mysqld
--修改主库备库服务器IP
--起主库
systemctl start mysqld
--主库增加新同步用户授权到新IP
grant replication slave on *.* to 'repl'@'192.168.3.4' identified by 'xxx';
--删除老的同步用户
delete from mysql.user where user='repl' and host='192.168.1.2';
flush privileges;
show grants for 'repl'@'192.168.3.4';
--查看主库当前的偏移量(如果使用gtid可以不用记录)
show master status \G
--起从库
systemctl start mysqld
stop slave;
change master to master_host='192.168.3.3', master_user='repl',master_password='xxx',master_port=3306,master_auto_position=1;
start slave;
grant replication slave on *.* to 'repl'@'192.168.3.3' identified by 'xxx';
flush privileges;
--删除老的同步用户
delete from mysql.user where user='repl' and host='192.168.1.1';
--确认同步状态
show slave status\G