http://www.cnblogs.com/cenalulu/p/4309009.html

http://txcdb.org/2016/03/%E7%B3%BB%E7%BB%9F%E8%A1%A8-mysql-gtid_executed   腾讯CDB团队

http://mysqllover.com/?p=594&utm_source=tuicool&utm_medium=referral

http://blog.itpub.net/29733787/viewspace-1462550/

http://blog.csdn.net/thundermeng/article/details/50401150

master:GTID:[my.cnf]server-id=xxmaster_info_repository = TABLE
relay_log_info_repository = TABLE
log_bin = bin.log
sync_binlog = 1
gtid_mode = on
enforce_gtid_consistency = 1
log_slave_updates
binlog_format = row
relay_log = relay.log
relay_log_recovery = 1
binlog_gtid_simple_recovery = 1

slave:[my.cnf]
master_info_repository = TABLE
relay_log_info_repository = TABLE
log_bin = bin.log
sync_binlog = 1
gtid_mode = on
enforce_gtid_consistency = 1
log_slave_updates
binlog_format = row
relay_log = relay.log
relay_log_recovery = 1
binlog_gtid_simple_recovery = 1skip-slave-updates

//Log-slave-update该参数在搭建master=>slave=>slave的架构时,需要配置。

GTID 变量:

GTID_PURGED:已经被删除的binlog的事务,它是GTID_EXECUTED的子集   //从上面就表现为已经执行了GTID_OWNED:  表示正在执行的事务的gtid以及对应的线程ID。GTID_EXECUTED 表示已经在该实例上执行过的事务; 执行RESET MASTER 会将该变量置空; 我们还可以通过设置GTID_NEXT执行一个空事务,来影响GTID_EXECUTEDGTID_NEXT是SESSION级别变量,表示下一个将被使用的GTID

RESET MASTER:
删所有的binary log文件
Deletes all binary log files listed in the index file, resets the binary log index file to be empty, and creates a new binary log file.清空gtid_purged与gtid_executed    设为empty string RESET MASTER also clears the values of the gtid_purged system variable as well as the global value of the gtid_executed system variable (but not its session value); that is, executing this statement sets each of these values to an empty string (''). In MySQL 5.7.5 and later, this statement also clears the mysql.gtid_executed table (see mysql.gtid_executed Table).This statement is intended to be used only when the master is started for the first time.ImportantRESET MASTER与PURGE BINARY LOGS不同之处
The effects of RESET MASTER differ from those of PURGE BINARY LOGS in 2 key ways:RESET MASTER removes all binary log files that are listed in the index file, leaving only a single, empty binary log file with a numeric suffix of .000001, whereas the numbering is not reset by PURGE BINARY LOGS.reset master 用在 复制状态为停止时,运行是不支持的,PURGE BINARY LOGS不受影响
RESET MASTER is not intended to be used while any replication slaves are running. The behavior of RESET MASTER when used while slaves are running is undefined (and thus unsupported), whereas PURGE BINARY LOGS may be safely used while replication slaves are running.

RESET SLAVE makes the slave forget its replication position in the master's binary log.This statement is meant to be used for a clean start: 

It clears the master info and relay log info repositories,      //删除master info and relay log info,如使用start slave 会重建文件,内容:slave IO,SQL 线程相关信息deletes all the relay log files, and starts a new relay log file. //delete all the relay log filesIt also resets to 0 the replication delay specified with the MASTER_DELAY option to CHANGE MASTER TO. To use RESET SLAVE, the slave replication threads must be stopped (use STOP SLAVE if necessary).   //要求replication threads 停止Note
All relay log files are deleted, even if they have not been completely executed by the slave SQL thread.  //所有的中继日志被删 (This is a condition likely to exist on a replication slave if you have issued a STOP SLAVE statement or if the slave is highly loaded.)RESET SLAVE does not change any replication connection parameters such as master host, master port, master user, or master password, which are retained in memory. This means that START SLAVE can be issued without requiring a CHANGE MASTER TO statement following RESET SLAVE.
RESET SLAVE ALL  //能够把所有的连接参数清除,而RESET SLAVE 不删Connection parameters are reset by RESET SLAVE ALL.(RESET SLAVE followed by a restart of the slave mysqld also does this.)

  

bin-log相关配制:

Binlog_format:STATEMENT|ROW|MIXED

参数也特别重要。从mysql5.1版本开始引入这个参数,该参数可以设置的值有STATEMENT\、ROW、MIXED;

(1)STATEMENT格式和之前的mysql版本一样,二进制日志文件记录的是日志的逻辑失SQL语句。

(2)在ROW格式下,二进制日志记录的不再是简单的SQL语句了,而是记录表的行更改情况,此时可以将InnoDB的事务隔离基本设为READ COMMITTED,以获得更好的并发性。

(3)MIXED格式下,mysql默认采用的STATEMENT格式进行二进制日志文件的记录,但是在一些情况下会使用ROW格式,可能的情况包括:

set session sql_log_bin=0/1 :可以会话级别控制SQL操作记录到BINLOG 中 max_binlog_size:单个文件最大大小,超过就切换Binlog_cache_size:binlog:缓存大小 (线程级别的分配)

binlog 删除:1.手动清理  1.purge{binary|master} logs to "bin-file-name"    purge{binary|master} logs before "datatime-expr"  2.停止mysql    rm命令清除 binlog    修改INDEX

2.自动清理expire_logs_days=N (1<=n<=99):二进制日志存放天数

sync_binlog=[N]表示每写缓存多少次就同步到磁盘,如果将N设置为1,则表示采用同步写磁盘的方式来写二进制日志,该参数很重要,这个以后还会提到。值得注意的是,在将该参数设置为1时,也应该将innodb_support_xa设为1来解决,这可以确保二进制日志和InnoDB存储引擎数据文件的同步。

中继日志:flush logs:切换中继日志relay_log_purge=0/1  是否自动删除    MHA中为0max_relay_log_size       定义文件大小
mysql> show master status;  //当前工作LOG文件
+------------+----------+--------------+------------------+-------------------------------------------+
| File       | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                         |
+------------+----------+--------------+------------------+-------------------------------------------+
| log.000003 |      194 |              |                  | 191f7a9f-ffa2-11e5-a825-00163e00242a:1-10 |
+------------+----------+--------------+------------------+-------------------------------------------+
1 row in set (0.00 sec)mysql> flush logs;         //切换日志文件
Query OK, 0 rows affected (0.05 sec)mysql> show master status;
+------------+----------+--------------+------------------+-------------------------------------------+
| File       | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                         |
+------------+----------+--------------+------------------+-------------------------------------------+
| log.000004 |      194 |              |                  | 191f7a9f-ffa2-11e5-a825-00163e00242a:1-10 |
+------------+----------+--------------+------------------+-------------------------------------------+
1 row in set (0.00 sec)

master 上的状态:

purge binlogs in 'log.000002';

slave上:change master to master_host='10.24.220.232',master_user='repl',master_password='123',master_port=3306,master_auto_position=1;

reset master:对gtid_executed与gtid_purged初始化为空字符串set global gtid_purged才可用

OK 强制同步成功接收到GTID集,

但(9,10)执行是不功的

slave上:

转载于:https://www.cnblogs.com/zengkefu/p/5478442.html

MYSQL 5.7 主从复制 -----GTID说明与限制 原创相关推荐

  1. MySQL 5.7 基于 GTID 的主从复制实践

    MySQL 5.7 基于 GTID 的主从复制实践 Posted by Mike on 2017-07-03 运维之美 Home About Archives Tags 在 「MySQL 5.7多源复 ...

  2. 菜鸟学Linux 第095篇笔记 MySQL 5.6主从复制

    菜鸟学Linux 第095篇笔记 MySQL 5.6主从复制 内容总览 主从服务器复制过滤 MySQL 5.6 简单主从模式配置步骤 mysql-proxy 主从服务器复制过滤 主服务器配置 基于数据 ...

  3. MySQL主从配置和gtid主从配置

    文章目录 1.为什么需要主从复制? 2.什么是mysql的主从复制? 3.GTID的工作原理: 4.GTID与传统主从复制的区别是什么 5.mysql主从 5. 1mysql主从配置 5.1.1 确保 ...

  4. mysql自定义gtid_mysql之gtid

    MYSQL-GITD: 5.6 gtid-mode=on enforce-gtid-consistency=1 log-slave-updates=1 log-bin= 在5.6版本开启GTID时必须 ...

  5. Maria数据库怎么复制到mysql_maria(mysql)的主从复制

    一.mariadb的基本操作 1.远程连接 mysql -uroot -p -h 127.0.0.1mysql-uroot -p -h 192.168.226.128 2.赋予远程连接的权限 gran ...

  6. 运维工程师必备之MySQL数据的主从复制、半同步复制和主主复制详解

    一.MySQL复制概述 ⑴.MySQL数据的复制的基本介绍 目前MySQL数据库已经占去数据库市场上很大的份额,其一是由于MySQL数据的开源性和高性能,当然还有重要的一条就是免费~不过不知道还能免费 ...

  7. mysql的innodb如何定位锁问题,mysql如何减少主从复制延迟?

    mysql的innodb如何定位锁问题: 在使用 show engine innodb status检查引擎状态时,发现了死锁问题 在5.5中,information_schema 库中增加了三个关于 ...

  8. MySQL 5.6版本GTID复制异常处理一例

    昨天处理了一个MySQL 5.6版本下开启GTID模式复制异常案例,MASTER上的任何操作都无法在SLAVE上应用,SLAVE的RELAY LOG里有记录,但SLAVE的BINLOG却找不到蛛丝马迹 ...

  9. mysql的innodb如何定位锁问题_mysql的innodb如何定位锁问题,mysql如何减少主从复制延迟?...

    mysql的innodb如何定位锁问题: 在使用 show engine innodb status检查引擎状态时,发现了死锁问题 在5.5中,information_schema 库中增加了三个关于 ...

最新文章

  1. Leetcode 51. N 皇后 (每日一题 20211008)
  2. 随机模块random、os模块、sys模块、shutil模块
  3. avr flash_AVR | USART家庭自动化
  4. java子类访问父类私有成员_Java中子类可以继承父类的私有成员,但是不能(直接)访问!!!...
  5. 【渝粤题库】 陕西师范大学 202331 证券投资学 作业(专升本)
  6. SLAM--搭建自己的视觉里程计VO-RGBD相机(一)
  7. MPI 初认识 (入门教程)
  8. 电影 1982年少林寺拍摄集锦
  9. AIX上通过FTP下载压缩包损坏
  10. oracle 启动与停止工作,win7出现已停止工作如ie已停止工作、word停止工作等等
  11. Linux 下 github 的使用
  12. Fildder拦截请求并修改请求参数
  13. OSI 七层模型和TCP/IP模型及对应协议(详解)
  14. EntityFramWork DbContext 自定义connectionString
  15. canvas五彩斑斓的粒子动画js特效
  16. 为什么很多人工作都不开心?(转)
  17. element 复杂表格渲染(1)
  18. 整车控制器(VCU)
  19. java 手写签名,signature java html5+ 手写签名 源码 Develop 238万源代码下载- www.pudn.com...
  20. 帝国cms手机和pc站数据同步建站教程

热门文章

  1. 论项目团队情商与项目团队绩效(转)
  2. Nas服务器使用xampp修改端口号
  3. 函数中{}输出格式详解(C#)
  4. eclipse-可视化swing设计插件windowbuilder
  5. [转]symbian基本类型转换
  6. 在 ASP.NET 2.0 中上载文件 —— 解决文件大小限制
  7. 世界上最经典的25句话
  8. 关于Redis的数据迁移(三种方法)
  9. 7.破解的最简单例子
  10. 设计模式复习-桥接模式