在MySQL主从复制出现错误时,例如二进制日志损坏的情况,可以利用sql_slave_skip_counter参数跨过一个事件继续复制,但是如果有很多个损坏执行这个参数就没有什么意义了..
例子如下:
查询从库
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Log_File: mysql-bin.000006
Slave_IO_Running: Yes
Slave_SQL_Running: No
Exec_Master_Log_Pos: 124646951
Last_Errno: 1062
Last_Error: Error 'Duplicate entry '87' for key 'PRIMARY'' on query. Default database: 'testdb'. Query: 'insert slave_no_skip1 values (87,'i10')'
查询主库
mysql> SHOW BINLOG EVENTS in 'mysql-bin.000006‘ from 124646951 limit 5;
+------------------+----------+------------+-----------+-------------+--------------------------------------------------------+
| Log_name | Pos | Event_type | Server_id | End_log_pos | Info |
+------------------+----------+------------+-----------+-------------+--------------------------------------------------------+
| mysql-bin.000006 | 124646951 | Query | 1 | 124646952 | use `testdb`; insert slave_no_skip1 values (87,'i10') |
解决:
停止stop slave;
set global sql_slave_skip_counter =1;
start slave;
在次查看
mysql> show slave status\G
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
恢复正常.OK了
阅读(18293) | 评论(0) | 转发(0) |