MySQL复制错误 The slave I/O thread stopsbecause master and slave have equal MySQL server UUIDs; these UUIDs must bedifferent for replication to work 解析

时间:2023-03-09 21:50:48
MySQL复制错误 The slave I/O thread stopsbecause master and slave have equal MySQL server UUIDs; these UUIDs must bedifferent for replication to work 解析

在搭建Mysql主从复制时候,在执行完相关操作以后,通过命令查看是否主从复制成功的时候

show slave status\G;

在“Slave_SQL_Running_State”中出现了“Fatal error: The slave I/O thread stopsbecause master and slave have equal MySQL server UUIDs; these UUIDs must bedifferent for replication to work.”这个错误。
当时以为是主节点服务器的UUID和从节点服务器网卡的UUID重复了,经过查看,发现他们并没有重复,然后重启服务器以后发现仍然没有成功。有点摸不着头脑。
通过上网搜索。发现原来是Mysql的一个配置文件auto.cnf里面记录了mysql服务器的uuid。

server_uuid:服务器身份ID。在第一次启动Mysql时,会自动生成一个server_uuid并写入到数据目录下auto.cnf文件里。

原来是这个uuid和主服务器的uuid重复了。(我是虚拟机环境,为了方便,先装好一台,并且装好MySQL,然后通过colone的方式复制出另外一台),然后经过修改auto.cnf文件中的server-uuid,重启mysql服务器,再查看mysql从节点的状态,恢复正常。