mysql5.7同步复制报错1060故障处理
mysql5.7同步复制报错故障处理
# 报错 1060,具体如下
Last_Errno: 1060
Last_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 0 failed executing transaction 'ANONYMOUS' at master log mysql-bin.000311, end_log_pos 352951786. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.
# 可以使用命令查看具体的执行sql语句
# 查找 positions 的位置向后10行
/usr/local/percona-server-5.7.14/bin/mysqlbinlog --no-defaults -v -v --base64-output=DECODE-ROWS mysql-bin.000311 | grep -A 10 352951786
# 用这条语句定位不到具体的执行sql
[root@newcms:/data/mysql_data]# /usr/local/percona-server-5.7.14/bin/mysqlbinlog --base64-output=DECODE-ROWS -v --start-position=352951786 --stop-position=352951786 mysql-bin.000311 | more
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
# 推荐使用如下定位命令:
[root@newcms:/data/mysql_data]# /usr/local/percona-server-5.7.14/bin/mysqlbinlog --no-defaults -v -v --base64-output=DECODE-ROWS mysql-bin.000311 | grep -A 10 352951786
#191202 9:13:24 server id 1189 end_log_pos 352951786 CRC32 0xb6b23b6f Query thread_id=4299701 exec_time=0 error_code=0
SET TIMESTAMP=1575249204/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/;
# 可以看到关键的执行sql语句,添加了字段,并且新增内容
ALTER TABLE `template_page_9342` ADD COLUMN `content` longtext NOT NULL
/*!*/;
# at 352951786
#191202 9:13:24 server id 1189 end_log_pos 352951851 CRC32 0x5636b59f Anonymous_GTID last_committed=3226 sequence_number=3227
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 352951851
#191202 9:13:24 server id 1189 end_log_pos 352951929 CRC32 0x8f64d217 Query thread_id=4299701 exec_time=0 error_code=0
SET TIMESTAMP=1575249204/*!*/;
BEGIN
/*!*/;
# at 352951929
#191202 9:13:24 server id 1189 end_log_pos 352952048 CRC32 0x96da7aa4 Table_map: `cms_global`.`template_fields` mapped to number 139
# at 352952048
# 对比主库和从库的表结构,可以看到是一致的,直接跳过即可
STOP SLAVE; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; START SLAVE;
# 主库
mysql> desc template_page_9342;
+-------------+----------------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+----------------------------------+------+-----+---------+----------------+
| page_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| title | char(100) | NO | | NULL | |
| keyword | char(250) | NO | | NULL | |
| description | char(200) | NO | | NULL | |
| url | varchar(255) | NO | | NULL | |
| entity_id | int(10) unsigned | NO | | NULL | |
| entity_name | char(100) | NO | | NULL | |
| is_default | enum('Y','N') | NO | | Y | |
| html_time | datetime | NO | | NULL | |
| action_name | char(20) | NO | | NULL | |
| user_id_a | int(11) unsigned | NO | | NULL | |
| user_id_e | int(11) unsigned | NO | | NULL | |
| add_time | datetime | NO | | NULL | |
| edit_time | datetime | NO | | NULL | |
| user_name | char(20) | NO | | NULL | |
| state | enum('able','disable','deleted') | NO | | able | |
| content | longtext | NO | | NULL | |
| style | longtext | NO | | NULL | |
| script | longtext | NO | | NULL | |
+-------------+----------------------------------+------+-----+---------+----------------+
# 从库
MySQL [cms_global]> desc template_page_9342;
+-------------+----------------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+----------------------------------+------+-----+---------+----------------+
| page_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| title | char(100) | NO | | NULL | |
| keyword | char(250) | NO | | NULL | |
| description | char(200) | NO | | NULL | |
| url | varchar(255) | NO | | NULL | |
| entity_id | int(10) unsigned | NO | | NULL | |
| entity_name | char(100) | NO | | NULL | |
| is_default | enum('Y','N') | NO | | Y | |
| html_time | datetime | NO | | NULL | |
| action_name | char(20) | NO | | NULL | |
| user_id_a | int(11) unsigned | NO | | NULL | |
| user_id_e | int(11) unsigned | NO | | NULL | |
| add_time | datetime | NO | | NULL | |
| edit_time | datetime | NO | | NULL | |
| user_name | char(20) | NO | | NULL | |
| state | enum('able','disable','deleted') | NO | | able | |
| content | longtext | NO | | NULL | |
| style | longtext | NO | | NULL | |
| script | longtext | NO | | NULL | |
+-------------+----------------------------------+------+-----+---------+----------------+
# 在主库中查找binlog报错,ERROR: Error in Log_event::read_log_event(): 'Sanity check failed' 是因为默认的mysqlbinlog命令是yum安装的低版本mysqlbinlog,需要指定我们运行的mysql高版本的命令
[root@newcms:/data/mysql_data]# mysqlbinlog --no-defaults -v -v --base64-output=DECODE-ROWS mysql-bin.000311 | grep -A 10 352951786
ERROR: Error in Log_event::read_log_event(): 'Sanity check failed', data_len: 31, event_type: 35
ERROR: Could not read entry at offset 123: Error in log format or read error.
[root@newcms:/data/mysql_data]# mysqlbinlog --base64-output=DECODE-ROWS -v --start-position=352951786 --stop-position=352951786 mysql-bin.000311 | more
ERROR: Error in Log_event::read_log_event(): 'Sanity check failed', data_len: 65, event_type: 34
ERROR: Could not read entry at offset 352951786: Error in log format or read error.
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
总结:
在MySQL主从同步集群部署中,经常会遇到主从不能同步的问题,以下对常见问题及解决办法进行了归纳列举
数据不一致:包括删除失败、主键重复、更新丢失
例如:
#更新丢失
Last_SQL_Errno: 1032
Last_SQL_Error: Could not execute Update_rows event on table social.test; Can't find record in 'jason', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND;the event's master log mysql-bin.000019, end_log_pos 4563
#主键重复
Last_SQL_Errno: 1062
Last_SQL_Error: Error 'Duplicate entry '1' for key 'PRIMARY'' on query. Default database: 'social'. Query: 'INSERT INTO `social`.`tool`(`createdat`, `updatedat`) VALUES ('2019-06-05 09:11:46', '2019-06-05 09:11:51')'
#删除失败
Last_SQL_Errno: 1032
Last_SQL_Error: Could not execute Delete_rows_v1 event on table social.player_role; Can't find record in 'player_role', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's master log mysql-bin.000013, end_log_pos 20064466
在master上,用mysqlbinlog 分析下出错的binlog日志在干什么:
[root@localhost ~]# mysqlbinlog --no-defaults -v -v --base64-output=DECODE-ROWS mysql-bin.000013 | grep -A 10 20064466
#190605 9:12:28 server id 1 end_log_pos 20064466 Delete_rows: table id 442 flags: STMT_END_F
### DELETE FROM `social`.`player_role`
### WHERE
### @1=1 /* INT meta=0 nullable=0 is_null=0 */
### @2=1 /* INT meta=0 nullable=0 is_null=0 */
### @3='2019-06-04 20:10:48' /* DATETIME(0) meta=0 nullable=1 is_null=0 */
### @4='2019-06-04 20:10:48' /* DATETIME(0) meta=0 nullable=1 is_null=0 */
# at 20064466
#190605 9:12:28 server id 1 end_log_pos 20064493 Xid = 414815
COMMIT/*!*/;
# at 20064493
#190605 9:13:00 server id 1 end_log_pos 20064531 GTID 0-1-9152684 trans
/*!100001 SET @@session.gtid_seq_no=9152684*//*!*/;
BEGIN
/*!*/;
# at 20064531
#190605 9:13:00 server id 1 end_log_pos 20064795 Query thread_id=1733 exec_time=0 error_code=0
SET TIMESTAMP=1559697180.6860/*!*/;
对于主键重复/删除失败/更新丢失,更新丢失主要是缺少更新的记录,进行补充下即可,主键重复/删除失败此时可以选择忽略错误,方法如下:
mysql> stop slave;
mysql> set global sql_slave_skip_counter=1;
mysql> start slave;
mysql> show slave status\G
字段不一致:包括字段重复、丢失、不够长等
#字段重复
Last_SQL_Errno: 1060
Last_SQL_Error: Error 'Duplicate column name 'del_flag'' on query. Default database: 'social'. Query: 'ALTER TABLE `social`.`player` ADD COLUMN `del_flag` int(11) NULL AFTER `detail`'
对于数据库字段的同步失败,只需要将主从数据库的字段名称、类型等调整一致即可。之后重启slave,查看主从同步是否恢复
主从表不一致
Last_SQL_Errno: 1146
Last_SQL_Error: Error executing row event: 'Table 'social.player_role' doesn't exist'
主从提示缺少表可以进行添加,多余表可以删除,保证主从表的一致即可。之后重启slave,查看主从同步是否恢复
mysql5.7同步复制报错1060故障处理的更多相关文章
- ecstore在MySQL5.7下维护报错WARNING:512 @ ALTER IGNORE TABLE
ecstore在MySQL5.7下维护报错WARNING:512 @ ALTER IGNORE TABLE 打开 /app/base/lib/application/dbtable.php , 替换A ...
- mysql5.6版本备份报错
MySQL5.6版本备份报错,密码不安全 [root@centos199 mysql]# mysqldump -uroot -ppassword cz-office > mysql38.sqlW ...
- git同步遇到报错
git同步遇到报错 “fatal: unable to access ‘https://github.com/ruanwenwu/newp.git/‘: Peer reports incompatib ...
- git同步遇到报错“fatal: unable to access 'https://github.com/lizhong24/mysite2.git/': Peer reports incompatible or unsupported protocol version.”
git同步遇到报错“fatal: unable to access 'https://github.com/lizhong24/mysite2.git/': Peer reports incompat ...
- 运维与开发的开车现场之MySQL5.7创建触发器报错解决过程
报错内容如下: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds ...
- GG同步sqlserver报错一个案例 Invalid date format
在里面Oracle表同步sqlserver时间,在sqlserver当应用程序数据的结束.您可能会遇到这个错误. 2014-05-17 17:20:24 WARNING OGG-01154 SQL e ...
- mysql5.7初始化密码报错 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before
mysql初始化密码常见报错问题1,mysql5.6是密码为空直接进入数据库的,但是mysql5.7就需要初始密码 cat /var/log/mysqld.log | grep password1 2 ...
- mysql5.7初始化密码报错ERROR1820(HY000):YoumustresetyourpasswordusingALTERUSERstateme
1,mysql5.6是密码为空直接进入数据库的,但是mysql5.7就需要初始密码 cat /var/log/mysqld.log | grep password 或者:grep 'temporary ...
- DG环境恢复同步遇到报错ORA-00353ORA-00334以及ORA-00600[2619], [47745]
问题说明 客户环境主库4节点RAC11.2.0.4,单实例DG环境,DG由于空间不足,导致同步中断,由于DG备库未应用的归档主库都再,本次恢复的方式,是开启dg mrp进程,自动同步追上主库. 以下遇 ...
随机推荐
- Nmon监控性能分析
一.CPU信息 1.折线图中蓝线为cpu占有率变化情况:粉线为磁盘IO的变化情况: 2.下面表各种左边的位磁盘的总体数据,包括如下几个: Avg tps during an interval 每个间隔 ...
- Springboot 2.1.1.RELEASE 版本 session保存到MySQL里面
1,pom.xml添加依赖: <!-- 数据库session管理 --> <dependency> <groupId>org.springframework.ses ...
- python笔记44-HTTP对外接口sign签名
前言 一般公司对外的接口都会用到sign签名,对不同的客户提供不同的apikey ,这样可以提高接口请求的安全性,避免被人抓包后乱请求. sign签名是一种很常见的方式 sign签名 签名参数sign ...
- C#程序保存dump文件
作用 程序异常崩溃前使用此类为进程创建DUMP文件,之后可以使用WinDbg等工具进行分析. 辅助类代码 using System; using System.Diagnostics; using S ...
- Oracle之常用sql
SQL函数 本文PDF下载 本文示例数据库下载 一旦成功地从表中检索出数据,就需要进一步操纵这些数据,以获得有用或有意义的结果.这些要求包括:执行计算与数学运算.转换数据.解析数值.组合值和聚合一个范 ...
- HDFS的读写流程
1.2. 客户端向NameNode发起创建文件的请求,在NameNode上创建一个文件名,并且返回一个输出流 3.客户端向输出流发起写入数据的请求 4.输出流向NameNode请求写数据,NameNo ...
- 怎么避免写bug?
1:关注可能的业务逻辑异常:业务逻辑异常 可以通过各种输入输出 和 预期进行比较 即可很快发现. 2:关注可能的运行逻辑异常: 如 copy对象: 对象引用等 这类异常只看代码逻辑时很难发现的:代码写 ...
- react-native 在iOS上使用http链接的图片地址不显示| iOS9 & iOS10 HTTP 不能正常使用的解决办法
https://segmentfault.com/a/1190000002933776 今天升级Xcode 7.0 bata发现网络访问失败.输出错误信息 The resource could not ...
- django-评论
视图函数views.py # 订单评论 class OrderCommentView(View): def get(self, request, order_id): # 获取用户信息 user = ...
- runloop是一个系统架构、是一个系统
信号与系统的系统: 事件源.派发系统.事件传播链.事件处理函数: 等组成的整体: 强调的重点是联系与结合.