【MySQL】Server-id导致Slave_IO_Running: No主从复制故障

发布时间:2020-08-08 07:16:10 作者:神谕丶
来源:ITPUB博客 阅读:252
【问题描述】:
在master停机维护启动服务之后,slave的Slave_IO_Running状态被置为NO
Slave_SQL_Running为Yes,猜测应该是master的锅

继续检查网络,权限等问题之后仍然为不可用
也尝试重新
change master to ...., ...., ....,
master_log_file = 'master-bin.034555',
master_log_pos = 98;
依旧不可用

  1. 160322 9:42:51 [Note] Slave SQL thread initialized, starting replication in log 'master-bin.034555' at position 98, relay log './mysqld-relay-bin.0000
  2. 01' position: 4
  3. 160322 9:43:01 [Note] Slave I/O thread: connected to master 'repl@*.*.*.*:3306', replication started in log 'master-bin.034555' at position 98
  4. 160322 9:43:01 [ERROR] Error reading packet from server: Misconfigured master - server id was not set ( server_errno=1236)
  5. 160322 9:43:01 [ERROR] Got fatal error 1236: 'Misconfigured master - server id was not set' from master when reading data from binary log
  6. 160322 9:43:01 [Note] Slave I/O thread exiting, read up to log 'master-bin.034555', position 98
  7. 160322 9:43:07 [Note] Error reading relay log event: slave SQL thread was killed

检查配置文件发现#server-id = xxx 被注释

【解决方案】:
由于server_id为“Dynamic Variable”
故到master中手动执行
  1. mysql> SET GLOBAL server_id=3028;
  2. Query OK, 0 rows affected (0.00 sec)

最后在将配置文件中添加
server-id=3028

在slave上检查:
  1. mysql> SHOW SLAVE STATUS\G
  2. *************************** 1. row ***************************
  3.              Slave_IO_State: Waiting for master to send event
  4.                 Master_Host: 192.168.30.28
  5.                 Master_User: repl
  6.                 Master_Port: 3306
  7.               Connect_Retry: 60
  8.             Master_Log_File: master-bin.034556
  9.         Read_Master_Log_Pos: 59312658
  10.              Relay_Log_File: mysqld-relay-bin.000002
  11.               Relay_Log_Pos: 64698308
  12.       Relay_Master_Log_File: master-bin.034555
  13.            Slave_IO_Running: Yes
  14.           Slave_SQL_Running: Yes
  15.                       …………………………
  16.       Seconds_Behind_Master: 10071
  17. 1 row in set (0.00 sec)

解决。


同样,某些时候在start slave时报错“The server is not configured as slave”,
同样也很有可能是server-id的缘故,只需要手动在主和从库上执行

SET GLOBAL server_id = xxx,并保证两台server-id不一样即可,最后写入my.cnf中。


作者微信公众号(持续更新)
【MySQL】Server-id导致Slave_IO_Running: No主从复制故障
推荐阅读:
  1. rsync同出出现 IO error encountered导致无法删除文件的解决方法
  2. JAVA.io读写文件的方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

io mysql server-id

上一篇:Metasploit命令info使用技巧

下一篇:开发者测试(4)-采用精准测试工具对dubbo微服务应用进行测试

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》