日期:2014-05-16 浏览次数:20894 次
?? 问题又出现了,nagios 又报警,mysql_AB error,检查从库
show slave status \G;?果然?
Slave_IO_Running: Yes
Slave_SQL_Running: No
而且出现了1062错误,还提示?
Last_SQL_Error: Error 'Duplicate entry '1001-164761-0' for key 'PRIMARY'' on query. Default database: 'bug'. Query: 'insert into misdata (uid,mid,pid,state,mtime) values (164761,1001,0,-1,1262623560)'
很显然,由于主库重启导致 从库数据不同步而且主键冲突。查看error 日志发现error日志文件变得好大,比以前大了将近好几倍,
tail -f mysql_error.log 最开始查看到的是这条信息
发现这条信息
?[ERROR] Slave SQL: Error 'Duplicate entry '1007-443786-0' for key 'PRIMARY'' on query. Default database: 'ufo'. Query: 'insert into misdata (uid,mid,pid,sta
te,mtime) values (443786,1007,0,-1,1262598003)', Error_code: 1062
100104 17:39:05 [Warning] Slave: Duplicate entry '1007-443786-0' for key 'PRIMARY' Error_code: 1062
100104 17:39:05 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'ufolog.000058
8' position 55793296
报错和上面的意思差不多,
最先想到的就是首先手动同步一下,从库上首先?stop slave;停止同步
进入主库锁表,
FLUSH TABLES WITH READ LOCK;
mysql>?show master status;
+-------------------+-----------+--------------+------------------+
| File????????????? | Position? | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+-----------+--------------+------------------+