问题描述

在主从复制中设置从库时报错:

Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.

原因分析

为了模拟两台服务器,我直接复制了一个虚拟机,导致主库和从库的服务器UUID相同,从库会停止I/O线程以防止数据不一致。

解决方案

修改从库的UUID:

  1. 退出MySQL服务
  2. 修改auto.cnf中的server_uuid

vim ./var/lib/mysql/auto.cnf

  1. 重启mysqld

systemctl restart mysqld

  1. 重新登录MySQL

mysql -uroot -p1234

  1. 建立从库与主库的连接

change master to master_host='192.168.49.129', master_user='xiaoming', master_password='1234', master_log_file='mysql-bin.000001', master_log_pos=441;

  1. 启动从库

start slave;

  1. 查看从库状态

show slave status;看到如下状态即为成功
image.pngimage.png
image.png

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐