Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids

很文博客hinven.com 数据库评论578字数 1150阅读模式
广告也精彩

mysql主从同步复制错误解决一例:Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids

蚊子今天下午搭了一主三从的mysql复制,结果所有服务器都配置好后,发现从上报如下的错误文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/17660.html

  1. Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).

意思就是从上的server_id和主的一样的,经查看发现从上的/etc/my.cnf中的server_id=1这行我没有注释掉(在下面复制部分我设置了server_id),于是马上把这行注释掉了,然后重启mysql,发现还是报同样的错误。文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/17660.html

使用如下命令查看了一下server_id文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/17660.html

  1. mysql> show variables like 'server_id';
  2. +---------------+-------+
  3. | Variable_name | Value |
  4. +---------------+-------+
  5. | server_id | 1 |
  6. +---------------+-------+
  7. 1 row in set (0.00 sec)

发现,mysql并没有从my.cnf文件中更新server_id,既然这样就只能手动修改了文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/17660.html

  1. mysql> set global server_id=2; #此处的数值和my.cnf里设置的一样就行
  2. mysql> slave start;

如此执行后,slave恢复了正常。文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/17660.html

不过稍后蚊子使用/etc/init.d/mysqld restart重启了mysql服务,然后查看slave状态,发现又出现了上面的错误,然后查看server_id发现这个数值又恢复到了1。文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/17660.html

之后蚊子又重新查看了一下/etc/my.cnf的内容,确认应该不是这个文件的问题,于是去google查了一下,看到mysql在启动的时候会查找/etc/my.cnf、DATADIR/my.cnf,USER_HOME/my.cnf。文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/17660.html

于是我执行了

  1. find / -name "my.cnf"

居然在/usr/local/mysql这个目录下发现了my.cnf文件,于是蚊子将这个文件删除了,然后再重启mysql服务,发现一切恢复了正常。如果有人也出现类似的问题,不妨试试这个办法吧。

工具:作品在线观看

女优:最新作品观看

中文:国语在线观看

weinxin
我的微信
扫一扫更精彩
大家的支持是我更新的动力!!!
 
广告也精彩
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证