报错:
1)查看slave状态
- Slave_IO_Running: No
- Slave_SQL_Running: Yes
查看error,有报错
- 130327 12:22:50 [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恢复正常
转载于:https://blog.51cto.com/xinfly/1163706