Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6664484
  • 博文数量: 1005
  • 博客积分: 8199
  • 博客等级: 中将
  • 技术积分: 13071
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-25 20:19
个人简介

脚踏实地、勇往直前!

文章分类

全部博文(1005)

文章存档

2020年(2)

2019年(93)

2018年(208)

2017年(81)

2016年(49)

2015年(50)

2014年(170)

2013年(52)

2012年(177)

2011年(93)

2010年(30)

分类: Mysql/postgreSQL

2018-05-19 09:01:42

从库报错,错误号为1062,违反唯一性约束

  1. mysql> show slave status \G;
  2. *************************** 1. row ***************************
  3.                Slave_IO_State: Waiting for master to send event
  4.                   Master_Host: 192.168.56.92
  5.                   Master_User: repl
  6.                   Master_Port: 3306
  7.                 Connect_Retry: 60
  8.               Master_Log_File: binlog.000066
  9.           Read_Master_Log_Pos: 554
  10.                Relay_Log_File: relaylog.000214
  11.                 Relay_Log_Pos: 317
  12.         Relay_Master_Log_File: binlog.000063
  13.              Slave_IO_Running: Yes
  14.             Slave_SQL_Running: No
  15.               Replicate_Do_DB:
  16.           Replicate_Ignore_DB: information_schema,performance_schema
  17.            Replicate_Do_Table:
  18.        Replicate_Ignore_Table:
  19.       Replicate_Wild_Do_Table:
  20.   Replicate_Wild_Ignore_Table:
  21.                    Last_Errno: 1062
  22.                    Last_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction 'cec9239c-4aa7-11e8-80b8-080027e9c966:13000740' at master log binlog.000063, end_log_pos 3625. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.
  23.                  Skip_Counter: 0
  24.           Exec_Master_Log_Pos: 2744
  25.               Relay_Log_Space: 3625921578
  26.               Until_Condition: None
  27.                Until_Log_File:
  28.                 Until_Log_Pos: 0
  29.            Master_SSL_Allowed: No
  30.            Master_SSL_CA_File:
  31.            Master_SSL_CA_Path:
  32.               Master_SSL_Cert:
  33.             Master_SSL_Cipher:
  34.                Master_SSL_Key:
  35.         Seconds_Behind_Master: NULL
  36. Master_SSL_Verify_Server_Cert: No
  37.                 Last_IO_Errno: 0
  38.                 Last_IO_Error:
  39.                Last_SQL_Errno: 1062
  40.                Last_SQL_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction 'cec9239c-4aa7-11e8-80b8-080027e9c966:13000740' at master log binlog.000063, end_log_pos 3625. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.
  41.   Replicate_Ignore_Server_Ids:
  42.              Master_Server_Id: 2
  43.                   Master_UUID: cec9239c-4aa7-11e8-80b8-080027e9c966
  44.              Master_Info_File: mysql.slave_master_info
  45.                     SQL_Delay: 0
  46.           SQL_Remaining_Delay: NULL
  47.       Slave_SQL_Running_State:
  48.            Master_Retry_Count: 86400
  49.                   Master_Bind:
  50.       Last_IO_Error_Timestamp:
  51.      Last_SQL_Error_Timestamp: 180518 19:40:14
  52.                Master_SSL_Crl:
  53.            Master_SSL_Crlpath:
  54.            Retrieved_Gtid_Set: cec9239c-4aa7-11e8-80b8-080027e9c966:13000738-13100742
  55.             Executed_Gtid_Set: 4873eeea-4114-11e8-a25a-080027aeb704:1-4,
  56. cec9239c-4aa7-11e8-80b8-080027e9c966:7000683-13000739
  57.                 Auto_Position: 0
  58.          Replicate_Rewrite_DB:
  59.                  Channel_Name:
  60.            Master_TLS_Version:
  61. 1 row in set (0.00 sec)


  62. ERROR:
  63. No query specified



尝试用pt-slave-restart跳过该错误
[root@pxc01 percona-toolkit-3.0.3]# pt-slave-restart --error-numbers=1062 -h localhost -uroot -pmysql
Can't locate Digest/MD5.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/bin/pt-slave-restart line 4261.
BEGIN failed--compilation aborted at /usr/local/bin/pt-slave-restart line 4261.



缺少安装了包,安装之。
yum -y install perl-Digest-MD5



再次执行
[root@pxc01 /]# pt-slave-restart --error-numbers=1062 -h localhost -uroot -pmysql -S /tmp/mysql.sock   
Cannot skip transactions properly because GTID is enabled and slave_parallel_workers > 0.  See 'GLOBAL TRANSACTION IDS' in the tool's documentation.



报错误,因为slave_parallel_workers 大于0,查看当前slave_parallel_workers=8
mysql> show variables like '%slave_parallel_workers%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| slave_parallel_workers | 8     |
+------------------------+-------+
1 row in set (0.00 sec)



先设置0,设置slave_parallel_workers=0
mysql> set global slave_parallel_workers=0;

[root@pxc01 /]# pt-slave-restart --error-numbers=1062 -h localhost -uroot -pmysql -S /tmp/mysql.sock
2018-05-18T20:54:55 S=/tmp/mysql.sock,h=localhost,p=...,u=root relaylog.000214         317 1062 
2018-05-18T20:54:56 S=/tmp/mysql.sock,h=localhost,p=...,u=root relaylog.000214        1229 1062 


执行成功,查看复制情况:

  1. mysql> show slave status \G;
  2. *************************** 1. row ***************************
  3.                Slave_IO_State: Waiting for master to send event
  4.                   Master_Host: 192.168.56.92
  5.                   Master_User: repl
  6.                   Master_Port: 3306
  7.                 Connect_Retry: 60
  8.               Master_Log_File: binlog.000066
  9.           Read_Master_Log_Pos: 554
  10.                Relay_Log_File: relaylog.000219
  11.                 Relay_Log_Pos: 761
  12.         Relay_Master_Log_File: binlog.000066
  13.              Slave_IO_Running: Yes
  14.             Slave_SQL_Running: Yes
  15.               Replicate_Do_DB:
  16.           Replicate_Ignore_DB: information_schema,performance_schema
  17.            Replicate_Do_Table:
  18.        Replicate_Ignore_Table:
  19.       Replicate_Wild_Do_Table:
  20.   Replicate_Wild_Ignore_Table:
  21.                    Last_Errno: 0
  22.                    Last_Error:
  23.                  Skip_Counter: 0
  24.           Exec_Master_Log_Pos: 554
  25.               Relay_Log_Space: 3625921578
  26.               Until_Condition: None
  27.                Until_Log_File:
  28.                 Until_Log_Pos: 0
  29.            Master_SSL_Allowed: No
  30.            Master_SSL_CA_File:
  31.            Master_SSL_CA_Path:
  32.               Master_SSL_Cert:
  33.             Master_SSL_Cipher:
  34.                Master_SSL_Key:
  35.         Seconds_Behind_Master: 0
  36. Master_SSL_Verify_Server_Cert: No
  37.                 Last_IO_Errno: 0
  38.                 Last_IO_Error:
  39.                Last_SQL_Errno: 0
  40.                Last_SQL_Error:
  41.   Replicate_Ignore_Server_Ids:
  42.              Master_Server_Id: 2
  43.                   Master_UUID: cec9239c-4aa7-11e8-80b8-080027e9c966
  44.              Master_Info_File: mysql.slave_master_info
  45.                     SQL_Delay: 0
  46.           SQL_Remaining_Delay: NULL
  47.       Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
  48.            Master_Retry_Count: 86400
  49.                   Master_Bind:
  50.       Last_IO_Error_Timestamp:
  51.      Last_SQL_Error_Timestamp:
  52.                Master_SSL_Crl:
  53.            Master_SSL_Crlpath:
  54.            Retrieved_Gtid_Set: cec9239c-4aa7-11e8-80b8-080027e9c966:13000738-13100742
  55.             Executed_Gtid_Set: 4873eeea-4114-11e8-a25a-080027aeb704:1-4,
  56. cec9239c-4aa7-11e8-80b8-080027e9c966:7000683-13100742
  57.                 Auto_Position: 0
  58.          Replicate_Rewrite_DB:
  59.                  Channel_Name:
  60.            Master_TLS_Version:
  61. 1 row in set (0.01 sec)


  62. ERROR:
  63. No query specified


已经恢复正常了,将slave_parallel_workers恢复回原来的值.
mysql> set global slave_parallel_workers=8;
Query OK, 0 rows affected (0.00 sec)

-- The End --

阅读(5497) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~