Last_SQL_Error: Could not execute Update_rows event on table eip_fileservice.T_FILE_LOCATION; Can't

一:问题描述

在从上查看状态,发现报错:

mysql> show slave status \G;

Last_SQL_Error: Could not execute Update_rows event on table eip_fileservice.T_FILE_LOCATION; Can't_第1张图片

 

Last_SQL_Error: Could not executeUpdate_rows event on table eip_fileservice.T_FILE_LOCATION; Can't find recordin 'T_FILE_LOCATION', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; theevent's master log master1-bin.001025, end_log_pos 713922982

 

二:解决步骤

2.1 在主库上查询相应的二进制日志记录

/usr/local/mysql/bin/mysqlbinlog  -v --stop-position=713922982/mysql_data1/mysql/master1-bin.001025 > /download/f.log

 

注意:用mysqlbinlog前一定要加上数据库安装路径,否则默认情况下调用的是系统默认安装的mysql中的mysqlbinlog

#查看记录end_log_pos 713922982的在第几行

[root@web_appdb_1 download]# cat/download/f.log | awk '/end_log_pos 713922982/ {print NR}'

106237810

 

#查看其前后多少行,找出其对应的sql语句

[root@web_appdb_1 download]# cat/download/f.log | awk 'NR==106237800,NR==106237860'

#160328 18:31:44 server id 1  end_log_pos 713922496     Xid = 22860913995

COMMIT/*!*/;

# at 713922496

#160328 18:31:44 server id 1  end_log_pos 713922575     Query       thread_id=3556858 exec_time=0    error_code=0

SET TIMESTAMP=1459161104/*!*/;

BEGIN

/*!*/;

# at 713922575

# at 713922660

#160328 18:31:44 server id 1  end_log_pos 713922660     Table_map: `eip_fileservice`.`T_FILE_LOCATION` mapped to number3474052

#160328 18:31:44 server id 1  end_log_pos 713922982     Update_rows:table id 3474052 flags: STMT_END_F

 

BINLOG '

EAj5VhMBAAAAVQAAAGSYjSoAAIQCNQAAAAEAD2VpcF9maWxlc2VydmljZQAPVF9GSUxFX0xPQ0FU

SU9OAAwIDwgPDw8ICAwMAwgI8AAsAR4AwAD+Dw==

EAj5VhgBAAAAQgEAAKaZjSoAAIQCNQAAAAEADP////8A8L1V/xMAAAAAIDI3ZDhlMjcwYTVlNDQz

MWNhOTZmYTVlMDUwZDlkOGY3AQAAAAAAAAALADIwMTYvMDMvMjUvA3N3ZiAzZWJkNmRkOTlhMjFj

YTkxYWE2YmM0Y2ExNTQ3YzEyN409AgAAAAAAAQAAAAAAAAAtQQXxVRIAAC5BBfFVEgAAAAAAADgA

AAAAAAAAAPC9Vf8TAAAAACAyN2Q4ZTI3MGE1ZTQ0MzFjYTk2ZmE1ZTA1MGQ5ZDhmNwEAAAAAAAAA

CwAyMDE2LzAzLzI1LwNzd2YgM2ViZDZkZDk5YTIxY2E5MWFhNmJjNGNhMTU0N2MxMjeNPQIAAAAA

AAIAAAAAAAAALUEF8VUSAABxLTPxVRIAAAAAAAA4AAAAAAAAAA==

'/*!*/;

### UPDATE eip_fileservice.T_FILE_LOCATION

### WHERE

###   @1=335500733

###  @2='27d8e270a5e4431ca96fa5e050d9d8f7'

###   @3=1

###   @4='2016/03/25/'

###   @5='swf'

###  @6='3ebd6dd99a21ca91aa6bc4ca1547c127'

###   @7=146829

###   @8=1

###   @9=2016-03-25 17:35:49

###   @10=2016-03-25 17:35:50

###   @11=0

###   @12=56

### SET

###   @1=335500733

###   @2='27d8e270a5e4431ca96fa5e050d9d8f7'

###   @3=1

###   @4='2016/03/25/'

###   @5='swf'

###  @6='3ebd6dd99a21ca91aa6bc4ca1547c127'

###   @7=146829

###   @8=2

###   @9=2016-03-25 17:35:49

###   @10=2016-03-28 18:31:53

###   @11=0

###   @12=56

DELIMITER ;

# End of log file

ROLLBACK /* added by mysqlbinlog */;

/*!50003 SETCOMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

 

2.2 验证是否是这条sql造成的错误

在主库上查询:

mysql> use eip_fileservice;

Database changed

mysql> select id from T_FILE_LOCATION where id = 335500733;

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

| id       |

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

| 335500733 |

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

1 row in set (0.01 sec)

在从库上查询:

mysql> select id from T_FILE_LOCATIONwhere id = 335500733;

Empty set (0.00 sec)

 

主库上果真没这条数据。

 

2.3 将该记录生成插入语句

mysql> use dba;

Database changed

 

mysql> create table t2 as select * fromeip_fileservice.T_FILE_LOCATION where id = 335500733;

Query OK, 1 row affected (0.11 sec)

Records: 1 Duplicates: 0  Warnings: 0

 

用navicat生成:

INSERT INTO `t2` VALUES (335500733,'27d8e270a5e4431ca96fa5e050d9d8f7', 1, '2016/03/25/', 'swf', '3ebd6dd99a21ca91aa6bc4ca1547c127',146829, 2, '2016-3-25 17:35:49', '2016-3-28 18:31:53', 0, 56);

 

将t2改成相应的表名:

 

INSERT INTO  eip_fileservice.T_FILE_LOCATION VALUES(335500733, '27d8e270a5e4431ca96fa5e050d9d8f7', 1, '2016/03/25/', 'swf', '3ebd6dd99a21ca91aa6bc4ca1547c127',146829, 2, '2016-3-25 17:35:49', '2016-3-28 18:31:53', 0, 56);

 

2.4 在slave上执行该插入语句

2.5 start slave

 

mysql> start slave;

Query OK, 0 rows affected (0.00 sec)

 

mysql> show slave status \G;

*************************** 1. row***************************

               Slave_IO_State: Waiting formaster to send event

                  Master_Host: ……

                  Master_User: replica

                  Master_Port: 3306

                Connect_Retry: 60

             Master_Log_File:master1-bin.001047

         Read_Master_Log_Pos: 778700768

               Relay_Log_File:web_appdb_10-relay-bin.000191

                Relay_Log_Pos: 714523965

       Relay_Master_Log_File: master1-bin.001025

            Slave_IO_Running: Yes

           Slave_SQL_Running: Yes

              Replicate_Do_DB:

         Replicate_Ignore_DB:

          Replicate_Do_Table:

      Replicate_Ignore_Table:

     Replicate_Wild_Do_Table: ccda.%,eip_fileservice.%

 Replicate_Wild_Ignore_Table:

                   Last_Errno: 0

                   Last_Error:

                 Skip_Counter: 0

         Exec_Master_Log_Pos: 714523817

              Relay_Log_Space: 25087745985

              Until_Condition: None

              Until_Log_File:

                Until_Log_Pos: 0

          Master_SSL_Allowed: No

          Master_SSL_CA_File:

          Master_SSL_CA_Path:

              Master_SSL_Cert:

           Master_SSL_Cipher:

               Master_SSL_Key:

        Seconds_Behind_Master: 70286

Master_SSL_Verify_Server_Cert: No

                Last_IO_Errno: 0

                Last_IO_Error:

               Last_SQL_Errno: 0

               Last_SQL_Error:

 Replicate_Ignore_Server_Ids:

            Master_Server_Id: 1

1 row in set (0.00 sec)

 

ERROR:

No query specified

 

mysql>

状态正常了,(*^__^*) 嘻嘻……

Seconds_Behind_Master: 70286

落后了19个小时。不过随着sql进程的开启,从库不再报错的话,这个时间会逐渐缩短的。从重放中继日志也需要时间的,特别是数据量特别大的时候。

 

你可能感兴趣的:(Last_SQL_Error: Could not execute Update_rows event on table eip_fileservice.T_FILE_LOCATION; Can't)