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=xx
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 = 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 = 1
skip-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_EXECUTED

GTID_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. Important RESET 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 files
It 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中为0
max_relay_log_size 定义文件大小
mysql> show master status;  //当前工作LOG文件
+------------+----------+--------------+------------------+-------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------+----------+--------------+------------------+-------------------------------------------+
| log. | | | | 191f7a9f-ffa2-11e5-a825-00163e00242a:- |
+------------+----------+--------------+------------------+-------------------------------------------+
row in set (0.00 sec) mysql> flush logs; //切换日志文件
Query OK, rows affected (0.05 sec) mysql> show master status;
+------------+----------+--------------+------------------+-------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------+----------+--------------+------------------+-------------------------------------------+
| log. | | | | 191f7a9f-ffa2-11e5-a825-00163e00242a:- |
+------------+----------+--------------+------------------+-------------------------------------------+
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='',master_port=,master_auto_position=; reset master:对gtid_executed与gtid_purged初始化为空字符串
set global gtid_purged才可用

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

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

slave上:

MYSQL 5.7 主从复制 -----GTID说明与限制 原创的更多相关文章

  1. percona mysql server5.7基于gtid的主从复制

    配置mysql基于gtid主从复制架构 一.二进制安装mysql [root@node5 data]# --Linux.x86_64.ssl101.tar.gz [root@node5 data]# ...

  2. Linux下MySQL主从复制(GTID)+读写分离(ProxySQL)-实施笔记

    GTID概念: GTID( Global Transaction Identifier)全局事务标识.GTID 是 5.6 版本引入的一个有关于主从复制的重大改进,相对于之前版本基于 Binlog 文 ...

  3. 为什么mysql要做主从复制?

    为什么MySQL要做主从复制(读写分离)? 通俗来讲,如果对数据库的读和写都在同一个数据库服务器中操作,业务系统性能会降低. 为了提升业务系统性能,优化用户体验,可以通过做主从复制(读写分离)来减轻主 ...

  4. MSYQL主从复制-Gtid方式

    目录 1.MYSQL主从复制-Gtid方式 1.环境准备 2.Master配置 3.Slave配置 4.报错&解决 我叫张贺,贪财好色.一名合格的LINUX运维工程师,专注于LINUX的学习和 ...

  5. MySQL 5.7主从复制实战篇

    MySQL 5.7主从复制实战篇 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.安装MySQL数据库并启动 1>.在MySQL官方下载相应的安装包(https://dev ...

  6. MySQL数据的主从复制、半同步复制和主主复制详解

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

  7. MySQL数据的主从复制、半同步复制和主主复制详解-转

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

  8. Mysql的ssl主从复制+半同步主从复制

    Mysql的ssl主从复制+半同步主从复制 准备工作 1.主从服务器时间同步 [root@localhost ~]# crontab -e */30 * * * * /usr/sbin/ntpdate ...

  9. Mysql高级之主从复制

    原文:Mysql高级之主从复制 主从复制不就是多台服务器嘛!,一个改变另一个也改变啦,内容其实都一样! 原理: 对数据库进行操作会生成一个文件,binlog(二进制文件),从服务器配置relaylog ...

随机推荐

  1. 【360开源】thinkjs:基于Promise的Node.js MVC框架 (转)

    thinkjs是360奇舞团开源的一款Node.js MVC框架,该框架底层基于Promise来实现,很好的解决了Node.js里异步回调的问题.360奇舞团(奇虎75Team),是奇虎360公司We ...

  2. shell变量定义

    http://blog.csdn.net/longxibendi/article/details/6125075 set - 读写变量语法:set varName ?value?描述:返回变量varN ...

  3. c++10 Seattle Clang error

    升级到C++Builder RAD 10 Settle 一些错误解决方法,使用LLVM  CLang编译器,BCC32C http://docwiki.embarcadero.com/RADStudi ...

  4. Django中如何使用django-celery完成异步任务1(转)

    原文链接: http://www.weiguda.com/blog/73/ 本篇博文主要介绍在开发环境中的celery使用,请勿用于部署服务器. 许多Django应用需要执行异步任务, 以便不耽误ht ...

  5. 【MySql】性能优化之分析命令

    一 当发现程序运行比较慢的时候,首先排除物力资源问题之后,就将注意力转向mysq数据库: 1.首先确定运行慢的sql语句: mysql> show full processlist; 2.确认低 ...

  6. OWA修改密码注意事项

    Exchange搭建参考 http://yuelei.blog.51cto.com/202879/76302 http://543925535.blog.51cto.com/639838/d-37/p ...

  7. MSSQL手札四 MSSQL的函数

    和oracle一样,sql也可以自己定义函数 一个返回值,引用DEMO如下: 编写一个函数,该函数,可以通过输入借书时间来判断是否到期,当借阅时间大于30天,返回已经过期:否则返回还未到期. CREA ...

  8. CCPC总结

    [印象·南阳] 10月15日出发,威海—烟台—郑州—南阳,一路上欢声笑语,从谁是卧底到各类纸牌游戏,也是欢乐.在从郑州到南阳的车上,对面的好像是河南当地的学长,感叹道工作不易的样子,说还是学生时代最为 ...

  9. css初始化代码方案

    (从已经死了一次又一次终于挂掉的百度空间人工抢救出来的,发表日期 2014-06-24) 为了消除各浏览器对css默认的设置,保持网页在各浏览器中的外观保持一致,初始化css就显得非常必要了!很多时候 ...

  10. 关于document.referrer的使用需要注意

    项目使用到一个场景,ajax请求返回无权限,跳回登录页面,登录后自动返回之前的浏览页,跳转由前端处理,于是想到document.referrer,但是对可靠性不确定,特意搜索了一下相关资料,大致整理如 ...