基于GTID Replication主从数据不一致操作
基本的M-S结构
+------+
| id |
+------+
| 1 |
| 2 |
| 4 |
+------+
3 rows in set (0.00 sec)
set sql_log_bin=OFF; insert into t1 values(5); set sql_log_bin=ON; insert into t1 values(6);
mysql> select * from t1; +------+ | id | +------+ | 1 | | 2 | | 4 | | 5 | | 6 | +------+ 5 rows in set (0.00 sec)
mysql> select * from testdb.t1; +------+ | id | +------+ | 1 | | 2 | | 4 | | 6 | +------+ 4 rows in set (0.00 sec)
update t1 set id=7 where id=5; insert into t1 values(8);mysql> select * from t1; +------+ | id | +------+ | 1 | | 2 | | 4 | | 7 | | 6 | | 8 | +------+ 6 rows in set (0.00 sec)
mysql> select * from testdb.t1; +------+ | id | +------+ | 1 | | 2 | | 4 | | 6 | +------+ 4 rows in set (0.00 sec)
mysql> show slave status\G *************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.203.135Master_User: replmonitorMaster_Port: 3306Connect_Retry: 60Master_Log_File: host2-bin.000002Read_Master_Log_Pos: 1146Relay_Log_File: host3-relay-bin.000003Relay_Log_Pos: 648Relay_Master_Log_File: host2-bin.000002Slave_IO_Running: YesSlave_SQL_Running: NoReplicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 1032Last_Error: Could not execute Update_rows event on table testdb.t1; Can't find record in 't1', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's master log host2-bin.000002, end_log_pos 875Skip_Counter: 0Exec_Master_Log_Pos: 660Relay_Log_Space: 1595Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_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: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 1032Last_SQL_Error: Could not execute Update_rows event on table testdb.t1; Can't find record in 't1', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's master log host2-bin.000002, end_log_pos 875Replicate_Ignore_Server_Ids:Master_Server_Id: 2Master_UUID: cd32a980-2a97-11e5-a344-000c2954ccdeMaster_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State:Master_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp: 150717 23:51:51Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set: cd32a980-2a97-11e5-a344-000c2954ccde:1-3Executed_Gtid_Set: cd32a980-2a97-11e5-a344-000c2954ccde:1Auto_Position: 1 1 row in set (0.00 sec)
2015-07-17 23:51:51 30750 [Warning] Slave: Can't find record in 't1' Error_code: 1032
2015-07-17 23:51:51 30750 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'host2-bin.000002' position 660
mysql> stop slave; Query OK, 0 rows affected (0.02 sec)mysql> set gtid_next='cd32a980-2a97-11e5-a344-000c2954ccde:2'; Query OK, 0 rows affected (0.00 sec)mysql> begin; Query OK, 0 rows affected (0.00 sec)mysql> commit; Query OK, 0 rows affected (0.00 sec)mysql> set gtid_next='AUTOMATIC'; Query OK, 0 rows affected (0.00 sec)mysql> start slave; Query OK, 0 rows affected (0.01 sec)即跳过有错误的GTID编号
mysql> show slave status\G *************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.203.135Master_User: replmonitorMaster_Port: 3306Connect_Retry: 60Master_Log_File: host2-bin.000002Read_Master_Log_Pos: 1146Relay_Log_File: host3-relay-bin.000005Relay_Log_Pos: 688Relay_Master_Log_File: host2-bin.000002Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 0Last_Error:Skip_Counter: 0Exec_Master_Log_Pos: 1146Relay_Log_Space: 1429Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_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: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id: 2Master_UUID: cd32a980-2a97-11e5-a344-000c2954ccdeMaster_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update itMaster_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set: cd32a980-2a97-11e5-a344-000c2954ccde:1-3Executed_Gtid_Set: cd32a980-2a97-11e5-a344-000c2954ccde:1-3Auto_Position: 1 1 row in set (0.00 sec)mysql> select * from testdb.t1; +------+ | id | +------+ | 1 | | 2 | | 4 | | 6 | | 8 | +------+ 5 rows in set (0.00 sec)
基于GTID Replication主从数据不一致操作相关推荐
- mysql gtid 主从_基于GTID搭建主从MySQL
基于gtid搭建主从MySQL 一.GTID的使用 想让主从之间使用gtid的方式同步数据,需要我们在配置文件中开启mysql对gtid相关的配置信息 找到my.cnf ,在mysqld模块中加入如下 ...
- mysql 主从 不一致_揭秘MySQL主从数据不一致
前言: 目前MySQL数据库最常用的是主从架构,大多数高可用架构也是通过主从架构演变而来.但是主从架构运行时间长久后容易出现数据不一致的情况,比如因从库可写造成的误操作或者复制bug等,本篇文章将会详 ...
- MySQL主从数据不一致,怎么办?
先给大家说个身边的故事. 小伙伴二狗最近面宇宙厂,前面被问MySQL索引.锁.主从复制原理时答的都很开心. 当面试官问到 :"你们遇到主从不一致的问题怎么解决呢?你有什么更好的方案吗?&qu ...
- Redis主从数据不一致及读取过期数据问题的解决方案
主从数据不一致问题 因为主从库间的命令复制是异步进行的,所以有可能客户端从从库中读取到的值和主库中的最新值并不一致. 具体来说,在主从库命令传播阶段,主库收到新的写命令后,会发送给从库.但是,主库并不 ...
- mysql主从复制、基于GTID的主从、半同步
使用的mysql版本5.7.17 一.主从复制 原理: 主从复制一共有三个进程,从库生成两个线程,一个I/O线程,一个SQL线程: i/o线程去请求主库的binlog,并将得到的binlog日志写到r ...
- mysql主从字符集不一致_MySQL多字节字符集造成主从数据不一致问题
问题产生线上一直有个历史遗留问题,最近DBA提了出来,所以跟了下代码,作了下简单分析,问题描述如下: 在master-slave的环境下,对master上的某个表中的数据插入,会导致master-sl ...
- mysql5.6,基于GTID的主从同步与延迟复制
GTID相关: 在mysql5.6之前,mysql主从复制是slave通过配置master的binlog位置实现的,且每一个slave自身的binlog却不同.而在mysql5.6版本后引入了GTID ...
- mysql防止从节点可写数据_mysql 主从数据不一致 Slave_SQL_Running: No 解决方法
在slave服务器上通过如下命令 MysqL> show slave status\G; 显示如下情况: Slave_IO_Running: Yes Slave_sql_Running: No ...
- mysql 并行复制搭建_基于GTID的主从实践系列之④并行复制搭建及测试
并行复制最早在5.6就搞出来了,是一个库级别的并行复制(slave_parallel_type可以有两个值:DATABASE 默认值,基于库的并行复制方式:LOGICAL_CLOCK:基于组提交的并行 ...
最新文章
- java实现异步调用实例
- 英雄多少钱steam_¥50元到手蓝宝石显卡?玩转GTAV轻松CSGO英雄联盟帧数144fps
- TF之NN:利用DNN算法(SGD+softmax+cross_entropy)对mnist手写数字图片识别训练集(TF自带函数下载)实现87.4%识别
- CollectionView
- Scala入门到精通——第九节 继承与组合
- matlab 神经网络设计多层隐含层_数据预测之BP神经网络具体应用以及matlab代码
- 微软商业智能BI知识整合篇-五大工具产品系列文章
- Andros系列排爆机器人原理_中国製造2025系列M之二:高档数控机床和机器人
- 上海交大计算机网络课程作业,上海交大计算机网络第四次作业详解.doc
- 五 .3D-2D:PnP问题求解 非线性法BA
- dos 退出for循环_循环?一次帮你搞定!
- 协同过滤算法_一文带你了解协同过滤的前世今生
- servlet 与 tomcat版本不匹配的问题
- 恒生电子:O45好在哪儿(深度)| 国君计算机李沐华
- 搭搭云中如何创建表单
- linux heartbeat rpm,linux之heartbeat高可用的简单配置
- USB 协议整理 九:USB 协议调试工程说明
- 参加南京俱乐部程序员聚会有感
- 程序员需要了解的.NET Framework 编程的好与坏
- CCS6创建TMS320F2812工程