Linux下MySQL主从同步故障:“Slave_IO_Running:No“的解决方法
可能有已下几种情况:
1. 在配置slave同步时因为slave访问master没有权限导致;
2. master上的mysql-bin.xxxxxx文件误删除;
3.由于克隆的机器导致uuid重复报错;
查看日志文件: tail /var/log/mysqld.log
2022-01-23T17:52:40.193201Z 3 [Note] Slave SQL thread for channel '' initialized, starting replication in log 'mysql-bin.000001' at position 4, relay log './MiWiFi-R4CM-srv-relay-bin.000001' position: 4
2022-01-23T17:52:40.195821Z 2 [Note] Slave I/O thread for channel '': connected to master 'root@192.168.31.200:3306',replication started in log 'mysql-bin.000001' at position 4
2022-01-23T17:52:40.197235Z 2 [ERROR] Slave I/O for channel '': 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. Error_code: 1593
2022-01-23T17:52:40.197247Z 2 [Note] Slave I/O thread exiting for channel '', read up to log 'mysql-bin.000001', position 4
2022-01-23T17:52:46.936852Z 4 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2022-01-23T17:53:28.859945Z 6 [Warning] IP address '192.168.31.123' could not be resolved: Name or service not known
2022-01-23T18:09:12.012742Z 9 [Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2022-01-23T18:09:12.014234Z 9 [Note] Slave I/O thread for channel '': connected to master 'root@192.168.31.200:3306',replication started in log 'mysql-bin.000001' at position 4
2022-01-23T18:09:12.015682Z 9 [ERROR] Slave I/O for channel '': 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. Error_code: 1593
2022-01-23T18:09:12.015700Z 9 [Note] Slave I/O thread exiting for channel '', read up to log 'mysql-bin.000001', position 4
show slave status\G
show variables like '%server_uuid%';
查询可得,由于克隆导致uuid确实一样,我记得配置文件当时加了新的,估计没设置成功,配置错误导致。
解决方法就是找到主机和从机的auto.cnf文件修改uuid值或删除auto.cnf这个文件。
执行find -name auto.cnf命令查看auto.cnf文件的位置,发现没有
通过命令找到mysql的安装目录:show variables like 'datadir';
cd /var/lib/mysql/
vi auto.cnf
sql执行命令生成新的uuid,将新的uuid设置进去,重启mysql
select uuid(); -- da0a30b5-7c7d-11ec-a327-000c29782b0a
service mysqld restart
使用命令行进入mysql:
mysql -u root -p
show slave status\G
这个问题解决了,下面报错,是表不存在,是主从复制的时候我把这个从服务器的相关数据都删除了,这个就不是文章报错相关的问题了。