iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >3分钟解决MySQL 1062 主从错误
  • 194
分享到

3分钟解决MySQL 1062 主从错误

主从错误MySQL 2023-01-31 07:01:23 194人浏览 独家记忆
摘要

1062错误----主键冲突,出现这种情况就是从库出现插入操作,主库又重新来了一遍,iothread没问题,sqlthread出错解决方案:Mysql> stop slave;   mysql> set global sql_s



1062错误----主键冲突,出现这种情况就是从库出现插入操作,主库又重新来了一遍,iothread没问题,sqlthread出错


解决方案:

Mysql> stop slave;
 
mysql> set global sql_slave_skip_counter=1;

mysql> start slave;





故障模拟:

从库如果误插入

mysql> insert into helei(text) values('iii');
Query OK, 1 row affected (0.28 sec)
mysql> select * from helei;
+----+------+
| id | text |
+----+------+
|  1 | aa  
|
|  2 | bb  
|
|  3 | cc  
|
|  4 | ee  
|
|  5 | ff  
|
|  6 | gg  
|
|  7 | hh  
|
|  8 | iii 
|
+----+------+
8 rows in set (0.00
sec)
 
mysql> show slave
status\G
***************************
1. row ***************************
               Slave_IO_State: Waiting for
master to send event
                  Master_Host: 192.168.1.250
                  Master_User: mysync
                  Master_Port: 2503306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000005
          Read_Master_Log_Pos: 2509
               Relay_Log_File:
HE1-relay-bin.000005
                Relay_Log_Pos: 480
        Relay_Master_Log_File: mysql-bin.000005
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
 
 
这时候从库是正常的,但由于从库私自插入数据,已经和主库不一致,如果这时主库也插入相同的数据
主库此时没有8,iii这条记录

mysql> select * from helei;
+----+------+
| id | text |
+----+------+
|  1 | aa  
|
|  2 | bb  
|
|  3 | cc  
|
|  4 | ee  
|
|  5 | ff  
|
|  6 | gg  
|
|  7 | hh  
|
+----+------+
7 rows in set (0.00
sec)
 
 
 
 
 
 
mysql>show slave status\G
***************************
1. row ***************************
               Slave_IO_State: Waiting for
master to send event
                  Master_Host: 192.168.1.250
                  Master_User: mysync
                  Master_Port: 2503306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000005
          Read_Master_Log_Pos: 2709
               Relay_Log_File:
HE1-relay-bin.000005
                Relay_Log_Pos: 480
        Relay_Master_Log_File: mysql-bin.000005
             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: 1062
                  
Last_Error: Could not execute Write_rows event on table test.helei;
Duplicate entry '8' for key 'PRIMARY', Error_code: 1062; handler error
HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.000005, end_log_pos
2678
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 2509
              Relay_Log_Space: 851
              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: NULL
Master_SSL_Verify_Server_Cert:
No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 1062
               Last_SQL_Error: Could not
execute Write_rows event on table test.helei; Duplicate entry '8' for key
'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's
master log mysql-bin.000005, end_log_pos 2678
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 2503306
                  Master_UUID:
f7c96432-f665-11e5-943f-000c2967a454
             Master_Info_File:
/data/mysql/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State:
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp: 160331 09:12:02
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set:
            Executed_Gtid_Set:
                Auto_Position: 0
1 row in
set (0.00 sec)

 

 

1062错误----主键冲突,出现这种情况就是从库出现插入操作,主库又重新来了一遍,iothread没问题,sqlthread出错

 

出现这样的问题,先停从库,set跳过这条事务

 

HE1从库操作

 

mysql> stop slave;
Query OK, 0 rows
affected (0.26 sec)
 
mysql> set global sql_slave_skip_counter=1;(这里写10也是一样的,最好不用这种方法,用pt-slave-restart,无需手动stop/start slave)
Query OK, 0 rows
affected (0.30 sec)
 
mysql> start slave;
Query OK, 0 rows
affected (0.04 sec)
 
mysql> show slave status\G
***************************
1. row ***************************
               Slave_IO_State: Waiting for
master to send event
                  Master_Host: 192.168.1.250
                  Master_User: mysync
                  Master_Port: 2503306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000005
          Read_Master_Log_Pos: 2909
               Relay_Log_File:
HE1-relay-bin.000006
                Relay_Log_Pos: 283
        Relay_Master_Log_File: mysql-bin.000005
             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: 2909
              Relay_Log_Space: 1214
              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: 0
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: 2503306
                  Master_UUID:
f7c96432-f665-11e5-943f-000c2967a454
             Master_Info_File:
/data/mysql/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read
all relay log; waiting for the slave I/O thread to update it
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set:
            Executed_Gtid_Set:
                Auto_Position: 0
1 row in set (0.00
sec)


您可能感兴趣的文档:

--结束END--

本文标题: 3分钟解决MySQL 1062 主从错误

本文链接: https://www.lsjlt.com/news/191499.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 3分钟解决MySQL 1062 主从错误
    1062错误----主键冲突,出现这种情况就是从库出现插入操作,主库又重新来了一遍,iothread没问题,sqlthread出错解决方案:mysql> stop slave;   mysql> set global sql_s...
    99+
    2023-01-31
    主从 错误 MySQL
  • 3分钟解决MySQL主从1594错误
    3分钟解决MySQL主从1594错误简介Part1:写在最前1594这个错误看起来挺严重的,会提示你binlog文件或者Relay log损坏了,例如binary log is corrupted、relay log is corrupte...
    99+
    2023-01-31
    主从 错误 MySQL
  • 3分钟解决MySQL 1032 主从错误
    3分钟解决MySQL 1032主从错误Part1:写在最前1032错误----现在生产库中好多数据,在从库误删了,生产库更新后找不到了,现在主从不同步了,再跳过错误也没用,因为没这条,再更新还会报错解决方案Part1:临时方案mysql&g...
    99+
    2023-01-31
    主从 错误 MySQL
  • 3分钟解决MySQL 1864 主从错误
        从字面意思看了一下是因为slave_pending_jobs_size_max默认值为16777216(16MB),但是slave接收到的slave_pending_jobs_size_max为17085453(17M);解决方案从...
    99+
    2023-01-31
    主从 错误 MySQL
  • mysql错误1062如何解决
    本篇内容主要讲解“mysql错误1062如何解决”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“mysql错误1062如何解决”吧! ...
    99+
    2024-04-02
  • mysql 出现1062错误的解决方法
    小编给大家分享一下mysql 出现1062错误的解决方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!mysql 出现1062错误的解决办法:首先打开mysql的配置文件【my.cnf】;然后...
    99+
    2024-04-02
  • MySQL主从复制错误如何解决
    MySQL主从复制错误如何解决,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。| 背景有客户咨询说,自己的从库show slave status...
    99+
    2024-04-02
  • mysql主从跳过错误的示例分析
    小编给大家分享一下mysql主从跳过错误的示例分析,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!非gtid:stop slave...
    99+
    2024-04-02
  • MySQL 主从复制错误1837
    MySQL5.6.37版本,某人在测试环境主库误操作执行删表操作,导致主从断开,在从库查看主从信息如下: Last_Errno: 1837 Last_Error: Worker 3 failed execu...
    99+
    2024-04-02
  • 3分钟了解Mysql空间搜GeoHash
    简单介绍:   Mysql 内置函数方案,适合于已有业务,新增加LBS功能,增加经纬度字段方可,避免数据迁移,在5.7.5后实现更多功能实现INNODB的空间搜方法,之前版本主要是对MYISAM的支持。    在此之前,InnoDB将几何数...
    99+
    2023-01-31
    空间 Mysql GeoHash
  • mysql主从同步错误Last_SQL_Errno: 1032处理分析
    在MySQL DBA 日常运维工作中,主从同步失败一定是会遇到的,最常见建是1032错误。 ...
    99+
    2024-04-02
  • mysql主键1068错误怎么解决
    mysql主键1068错误怎么解决:1、删除主键;2、输入代码,点击执行,删除原有主键,然后进行主键操作。通常mysql主键出现1068错误的原因:是因为主键一旦被定义,就无法再进行更改,直接修改主键属性会被看作定义第二个主键,从而导致出错...
    99+
    2024-04-02
  • MySQL 5.6主从报错分析
    本篇内容主要讲解“MySQL 5.6主从报错分析”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“MySQL 5.6主从报错分析”吧!1. 问题现象版本:MySQL 5.6,采用传统 binlog ...
    99+
    2023-06-14
  • mysql主从同步怎么跳过错误
    这篇文章给大家分享的是有关mysql主从同步怎么跳过错误的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。mysql主从同步跳过错误的方法:1、跳过指定数量的事务,代码为【mysql...
    99+
    2024-04-02
  • redis主从连接不成功错误问题及解决
    目录Redis主从连接不成功错误问题出现了最后找到了解决方法总结redis主从连接不成功错误 安装完redis后,设置主从,在从服务器上运行 127.0.0.1:6379> slaveof 192.168.159....
    99+
    2024-01-29
    redis主从 redis主从连接 redis主从连接不成功
  • 怎么解决mysql主从复制报错问题
    这篇文章主要介绍“怎么解决mysql主从复制报错问题”,在日常操作中,相信很多人在怎么解决mysql主从复制报错问题问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么解决my...
    99+
    2024-04-02
  • 1分钟解决github push/pull报错443
    打开https://www.ipaddress.com/ 复制如图IP地址 文件夹打开C:\Windows\System32\drivers\etc,复制hosts文件,粘贴到桌面 在桌面用记事本打...
    99+
    2023-09-08
    github 443 git
  • mysql主从不同步报错Last_Errno 1197的解决方法
    本篇内容主要讲解“mysql主从不同步报错Last_Errno 1197的解决方法”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“mysql主从不同步报错Last...
    99+
    2024-04-02
  • MySQL主从延迟、读写分离问题如何解决
    本文小编为大家详细介绍“MySQL主从延迟、读写分离问题如何解决”,内容详细,步骤清晰,细节处理妥当,希望这篇“MySQL主从延迟、读写分离问题如何解决”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,...
    99+
    2024-04-02
  • 一分钟带你解决“command not found“报错
    长话短说, "command not found"   找不到命令 这类错误出现的原因有很多,根据具体情况分析,常见的有以下3种 不是可执行命令,也就是你输入的代码不合法,没有被定义 [root@localhost test]# jsjsj...
    99+
    2023-09-01
    linux 服务器 centos 运维
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作