1 / 9

MySQL 5.6 GTID 复制介绍 讲师:贺春旸 博客: hcymysql.blog.51cto/

MySQL 5.6 GTID 复制介绍 讲师:贺春旸 博客: http://hcymysql.blog.51cto.com/. 什么是 GTID ?. ● 通过 uuid() 函数随机生成的一组 36 位唯一的标示符,可查看 auto.conf 文件,例: source_id : transaction_id 3E11FA47-71CA-11E1-9E33-C80AA9429562 : 1 ● 事务 ID 是按照顺序排列的,例: source_id : trx_start-trx_stop

kevyn-boyer
Download Presentation

MySQL 5.6 GTID 复制介绍 讲师:贺春旸 博客: hcymysql.blog.51cto/

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MySQL 5.6 GTID复制介绍 讲师:贺春旸 博客:http://hcymysql.blog.51cto.com/

  2. 什么是GTID? ● 通过uuid()函数随机生成的一组36位唯一的标示符,可查看auto.conf文件,例: source_id:transaction_id 3E11FA47-71CA-11E1-9E33-C80AA9429562:1 ● 事务ID是按照顺序排列的,例: source_id:trx_start-trx_stop 3E11FA47-71CA-11E1-9E33-C80AA9429562:1-5 ● MySQL5.6版本才支持GTID,MariaDB10的GTID跟MySQL5.6不兼容。引擎必须是InnoDB,不支持MyISAM。 ● 减少了DBA的工作量,主从切换时,无需人工找binlog文件和position偏移量。 ● 有效的保证了数据的完整性和安全性。

  3. GTID工作流程 • GTID-based replication • Slave发送它已经执行过的GTID事务, • 之后Master把后面的事务发送给slave, • 开始同步复制。

  4. GTID故障切换

  5. 开启GTID ● 主和从增加下面的参数到my.cnf配置文件里,并重启MySQL服务进程才能生效。 gtid_mode = ON log_bin = mysql-bin log_slave_updates = 1 enforce_gtid_consistency = 1 ● 到MySQL5.7,改进了重启生效这一问题。 ● CHANGE MASTER TO …, MASTER_AUTO_POSITION = 1; ● set global sql_slave_skip_counter=1;语法不支持,如果跳过一条事务,需要插入一条空事务,例: STOP SLAVE; SET GTID_NEXT="7d72f9b4-8577-11e2-a3d7-080027635ef5:5"; BEGIN; COMMIT; SET GTID_NEXT="AUTOMATIC"; START SLAVE;

  6. 搭建GTID复制 ● mysqldump ­­master­data=2,现在包含了GTID信息。 第一步, SET GLOBAL gtid_purged="XXXX:X“; 第二步, CHANGE MASTER TO …, MASTER_AUTO_POSITION = 1; ● Percona XtraBackup xtrabackup_binlog_info文件,现在包含了GTID信息。 第一步, SET GLOBAL gtid_purged="XXXX:X“; 第二步, CHANGE MASTER TO …, MASTER_AUTO_POSITION = 1;

  7. GTID复制状态信息 ● Retrieved_Gtid_Set:表示接收到主库上的GTID ● Executed_Gtid_Set:表示执行完主库上的GTID ● Auto_position:1 表示已经采用GTID复制模式 show slave status\G;

  8. GTID复制状态信息 gtid_executed:表示执行完主库上的GTID show global variables like 'gtid_executed';

  9. GTID复制局限性 ● 性能—因为每台机器都要开启log_bin+ log_slave_updates,所以会增加IO的开销,是否采用GTID复制模式,需要在安全和性能上做一下权衡。 ● 不支持create table t5 select * from t1;语句,这会拆分成两个事务。 ● 不支持MyISAM引擎,只支持InnoDB引擎。

More Related