mysql主从库不同步问题
Slave_SQL_Running: No 问题
Last_Error: Could not execute Update_rows event on table zabbix.item_discovery; Can't find record in 'item_discovery', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000016, end_log_pos 599045736
主库上执行/usr/local/mysql/bin/mysqlbinlog -v --base64-output=DECODE-ROWS /var/lib/mysql/mysql-bin.000016 | grep -A '100' 608703700
查看update语句涉及的记录在从库上有没有,如果只是一条没有,insert,如果多条没有执行以下操作
1、在备库上stop slave;
2、在主库上停止写入:flush tables with read lock; 多show master status几遍,log号应不变
3、用mysqldump导出主库备份上传到备库 mysqldump -uroot -p --all-databases > m.sql scp m.sql root@xxxx:/root
用mysql -uroot -p < m.sql
4、主库show master status;记录binlog File 文件名称和 Position值
5、备库上CHANGE MASTER TO MASTER_HOST=
'1.1.1.1', MASTER_USER=
'replication', MASTER_PASSWORD=
'mima@143', MASTER_LOG_FILE=
'mysql-bin.000001', MASTER_LOG_POS=
154;
6、在备库上start slave;
7、在备库上show slave status;
8、主库上unlock tables;