Error_code:1032;handlererrorHA _ERR_KEY_NOT_FOUND;
end_log_po25theevent\’masterlogmysql-bin.000006.4
处置惩罚方式:
而slave上找不到故报错,因为master要删除一条记录。这类情况主上都将其删除了那么从机可以或许直接跳过。可用饬令:
stopslave;
setglobalsql_slave_skip_counter=1;
startslave;
可用我写的一个脚本skip_error_replcation.sh默认跳过10个错误(只针对这类情况才跳,如果这类情况许多。其他情况输出错误成果,等候处置惩罚)
不是无论什么错误都一律跳过。这个剧本是参考maakit工具包的mk-slave-restart情理用shell写的功能上定义了一些自己的器材。
主键重复
又在master上插入了同一条记录。slave已经有该记录。
Last_SQL_Error:CouldnotexecutWrite_roweventontablhcy.t1;
Duplicentri\’2\’forkei\’PRIMA RY\’.
Error_code:1062;
end_log_po92handlererrorHA _ERR_FOUND_DUPP_KEY;theevent\’masterlogmysql-bin.000006.4
处置惩罚方式:
slave上用deschcy.t1;先看下表结构:
mysql>deschcy.t1;
+——-+———+——+—–+———+——-+
|Field|Type|Null|Kei|Default|Extra|
+——-+———+——+—–+———+——-+
|id|int11|NO|PRI|0||
|name|char4|YES||NULL||
+——-+———+——+—–+———+——-+
删除反复的主键
mysql>deletfromt1whereid=2;
1rowaffect0.00secQueriOK.
mysql>startslave;
0rowaffect0.00secQueriOK.
mysql>showslavestatusG;
Slave_IO_Running:Yes
Slave_SQL_Running:Yes
mysql>select*fromt1whereid=2;
master上和slave上再分袂赞成一下。
更新丧失
而slave上找不到丧失了数据。master上更新一条记录。
Last_SQL_Error:CouldnotexecutUpdate_roweventontablhcy.t1;
Can\’tfindrecordin\’t1\’.
Error_code:1032;
handlererrorHA _ERR_KEY_NOT_FOUND;
end_log_po79theevent\’masterlogmysql-bin.000010.4
处置惩罚方式:
用mysqlbinlog分析下出错的binlog日记在干什么。master上。
/usr/local/mysql/bin/mysqlbinlog–no-default-v-v–base64-output=DECODE-ROWSmysql-bin.000010|grep-A \’10\’794
#12030212:08:36serverid22end_log_po794Update_rows:tablid33flags:STMT_END_F
###UPDA TEhcy.t1
###WHERE
###@1=2
###@2=\’bbc\’
###SET
###@1=2
###@2=\’BTV\’
#at794
#12030212:08:36serverid22end_log_po821Xid=60
COMMIT;
DELIMITER;
#Endoflogfile
ROLLBA CK;
;
查找下更新后的那条记录,slave上。应当是不存在
mysql>select*fromt1whereid=2;
Emptiset0.00sec
尔后再到master检查
mysql>select*fromt1whereid=2;
+—-+——+
|id|name|
+—-+——+
|2|BTV|
+—-+——+
1rowinset0.00sec
尔后跳过报错即可。把丢失的数据在slave上填补。
\’BTV\’mysql>insertintot1valu2.;
1rowaffect0.00secQueriOK.
mysql>select*fromt1whereid=2;
+—-+——+
|id|name|
+—-+——+
|2|BTV|
+—-+——+
1rowinset0.00sec
mysql>stopslave;setglobalsql_slave_skip_counter=1;startslave;
0rowaffect0.01secQueriOK.
0rowaffect0.00secQueriOK.
0rowaffect0.00secQueriOK.
mysql>showslavestatusG;
Slave_IO_Running:Yes
Slave_SQL_Running:Yes
中继日志损坏
slave中继日志relay-bin破坏。
Last_SQL_Error:Errorinitirelailogposition:I/Oerrorreadtheheaderfromthebinarilog
Last_SQL_Error:Errorinitirelailogposition:Binloghabadmagicnumber;
It\’notabinarilogfilethatcanbeusbythiversionofMySQL
手工修复
尔后重新做同步,处置惩罚方式:找到同步的binlog和POS点。这样就可以有新的中继日值了
例子:
mysql>showslavestatusG;
***************************1.row***************************
Master_Log_File:mysql-bin.000010
Read_Master_Log_Pos:1191
Relay_Log_File:vm02-relay-bin.000005
Relay_Log_Pos:253
Relay_Master_Log_File:mysql-bin.000010
Slave_IO_Running:Yes
Slave_SQL_Running:No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:1593
Last_Error:Errorinitirelailogposition:I/Oerrorreadtheheaderfromthebinarilog
Skip_Counter:1
Exec_Master_Log_Pos:821
Slave_IO_Run领受masterbinlog消息
Master_Log_File
Read_Master_Log_Pos
Slave_SQL_Run执行写操作
Relay_Master_Log_File
Exec_Master_Log_Pos
以执行写的binlog和POS点为准。
Relay_Master_Log_File:mysql-bin.000010
Exec_Master_Log_Pos:821
mysql>stopslave;
0rowaffect0.01secQueriOK.
MA STER_LOG_POS=821mysql>CHA NGEMA STERTOMA STER_LOG_FILE=\’mysql-bin.000010\’.;
0rowaffect0.01secQueriOK.
mysql>startslave;
0rowaffect0.00secQueriOK.
mysql>showslavestatusG;
***************************1.row***************************
Slave_IO_State:Waitformastertosendevent
Master_Host:192.168.8.22
Master_User:repl
Master_Port:3306
Connect_Retry:10
Master_Log_File:mysql-bin.000010
Read_Master_Log_Pos:1191
Relay_Log_File:vm02-relay-bin.000002
Relay_Log_Pos:623
Relay_Master_Log_File:mysql-bin.000010
Slave_IO_Running:Yes
Slave_SQL_Running:Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:0
Last_Error:
Skip_Counter:0
Exec_Master_Log_Pos:1191
Relay_Log_Space:778
Until_Condition:None
Until_Log_File:
Until_Log_Pos:0
Master_SSL_A llowed:No
Master_SSL_CA _File:
Master_SSL_CA _Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:0
Master_SSL_Verify_Server_Cert:No
Last_IO_Errno:0
Last_IO_Error:
Last_SQL_Errno:0
Last_SQL_Error: