博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

gtid error set test

Posted on 2017-11-22 22:57  moss_tan_jun  阅读(163)  评论(0编辑  收藏  举报

1、从库报主键重复(Errno: 1062)
#create test data 1062
create table t1 (id tinyint not null primary key,ename varchar(20),blog varchar(50));
insert into t1 values(1,'leshami','http://blog.csdn.net/leshami');
insert into t1 values(2,'robin','http://blog.csdn.net/robinson_0612');
set sql_log_bin=off;
delete from t1 where ename='robin';
set sql_log_bin=on;
insert into t1 values(2,'robin','http://blog.csdn.net/robinson_0612');

#set
stop slave;
delete from t1 where ename='robin';
start slave;
show slave status \G

====================
2、从库报找不到对应的被更新的记录(Errno: 1032)
#slave
delete from t1 where ename='leshami';
#master
update t1 set blog='http://blog.csdn.net/robinson_0612' where ename='leshami';
#slave
show slave status \G
---set slave
stop slave sql_thread;
insert into t1 values(1,'leshami','http://blog.csdn.net/leshami');
start slave sql_thread;
show slave status \G

3、从库找不到对应的被删除的记录(Errno: 1032)
#slave
delete from t1 where ename='robin';
#master
delete from t1 where ename='robin';
#slave
show slave status \G
--set slave
stop slave sql_thread;
set gtid_next='6ad6c92a-13c2-11e7-8929-000c29511923:38';
begin;commit;
set gtid_next='AUTOMATIC';
start slave sql_thread;
show slave status \G

4、延迟从修复主库意外truncate
#master
create table t2 (id tinyint not null primary key, ename varchar(20),blog varchar(50));
insert into t2 values(1,'leshami','http://blog.csdn.net/leshami');
insert into t2 values(2,'robin','http://blog.csdn.net/robinson_0612');
select * from t2;

#slave
stop slave sql_thread;
CHANGE MASTER TO MASTER_DELAY = 300;
start slave sql_thread;
show slave status \G

#master
show master status\G
truncate table t2;
show master status\G

#slave
stop slave sql_thread;
set gtid_next='6ad6c92a-13c2-11e7-8929-000c29511923:44';
begin;commit;
set gtid_next='AUTOMATIC';
start slave sql_thread;
show slave status \G

5、主库binlog被purge的情形(Errno: 1236)

 

get error gtid

----

#!/usr/bin/python
import re

gtid = "this iekdkdk '6ad6c92a-13c2-11e7-8929-000c29511923:534878' edkdke iekdk iekdk k"
grs= "[0-9,a-z]{8}-[0-9,a-z]{4}-[0-9,a-z]{4}-[0-9,a-z]{4}-[0-9,a-z]{12}:\d+"
rev = re.findall(grs,gtid)
print(rev[0])