天天看点

mysql 主从复制常见错误

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,发现还是报同样的错误。

使用如下命令查看了一下server_id

复制代码

代码如下:

mysql> show variables like

‘server_id‘;

+---------------+-------+

| Variable_name | Value |

| server_id | 1 |

1 row in set (0.00 sec)

发现,mysql并没有从my.cnf文件中更新server_id,既然这样就只能手动修改了

mysql> set global server_id=2;

#此处的数值和my.cnf里设置的一样就行

mysql> slave start;

如此执行后,slave恢复了正常。 

继续阅读