标签:temp 概念 ever ids global inline stop 生成 evel
mysql> insert into user_myisam values (3,100); -- myisam每条sql自动提交,所以myisam中不存在事务的概念Executed_Gtid_Set: 59fe7a3e-9dd6-11e7-9d6c-000c29e57c69:1-68
mysql> create table t1 select * from user_innodb;ERROR 1786 (HY000): CREATE TABLE ... SELECT is forbidden when @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1.
mysql> begin;mysql> update user_innodb set money=100 where id=1;mysql> update user_myisam set money=100 where id=1;ERROR 1785 (HY000): When @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1, updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.
The slave IO thread stops because the master has @@GLOBAL.GTID_MODE ON and this server has @@GLOBAL.GTID_MODE OFF。
存储已经执行过,并且记录到 binlog 的全局事务 ID 集合。它对应的 MySQL variable 是 gtid_executed,可以用命令:
2. gtid_purgedlogged_gtids 用来判断 MySQL 有没有执行某个事务。例如,在 Master 发送 binlog 时,MySQL 5.6 能够根据 Slave 提供的 logged_gtids 记录,自动过滤 binlog 中不需要执行的事务
3. gtid_owned记录从 binlog 删除的全局事务 ID 集合。它对应的 MySQL Global variable 是:gtid_purged 。每当 MySQL 5.6 调用 purge_logs 删除 binlog 时,会顺带更新 gtid_purged 的内容。这是通过读剩下的 binlog 文件实现的
4. gtid_next正在由线程执行的全局事务 ID 集合。它对应的 MySQL variable 是:gtid_owned
mysql> show slave status \GLast_SQL_Error: Worker 3 failed executing transaction ‘59fe7a3e-9dd6-11e7-9d6c-000c29e57c69:17‘ at master log mysql-bin.000002, end_log_pos 3255; Error executing row event: ‘Table ‘test.t1‘ doesn‘t existRetrieved_Gtid_Set: 59fe7a3e-9dd6-11e7-9d6c-000c29e57c69:1-17Executed_Gtid_Set: 59fe7a3e-9dd6-11e7-9d6c-000c29e57c69:1-16,29bd8c99-9e4d-11e7-a072-000c29d00b2d:1,Auto_Position: 1
主库备份# mysqldump -uroot -p123123 -h127.0.0.1 --single-transaction --set-gtid-purged=off --triggers --routines --events test t1 >/tmp/t1.sql从库恢复# cat t1.sql |mysql -uroot -p123123 test
> stop slave;> SET @@SESSION.GTID_NEXT= ‘59fe7a3e-9dd6-11e7-9d6c-000c29e57c69:17‘/*!*/;> show variables like ‘%gtid%_next‘;> BEGIN;COMMIT;> SET gtid_next = ‘AUTOMATIC‘;> START SLAVE;
# mysqldump -uroot -p123123 -h127.0.0.1 --single-transaction --set-gtid-purged=on --triggers --routines --events test t1 >/tmp/t1.sql
# cat /tmp/t1.sql |egrep SET |egrep -v "^/"SET @MYSQLDUMP_TEMP_LOG_BIN = @@SESSION.SQL_LOG_BIN;SET @@SESSION.SQL_LOG_BIN= 0;SET @@GLOBAL.GTID_PURGED=‘59fe7a3e-9dd6-11e7-9d6c-000c29e57c69:1-22‘;) ENGINE=InnoDB DEFAULT CHARSET=latin1;SET @@SESSION.SQL_LOG_BIN = @MYSQLDUMP_TEMP_LOG_BIN;
> reset master; //清空GTID_EXECUTED -- @@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty.# mysql -uroot -p123123 test < t1.sql -- 会执行备份文件中的SET @@GLOBAL.GTID_PURGED。> show slave status \GRetrieved_Gtid_Set: 59fe7a3e-9dd6-11e7-9d6c-000c29e57c69:1-22Executed_Gtid_Set: 59fe7a3e-9dd6-11e7-9d6c-000c29e57c69:1-22> start slave;
# mysqldump -uroot -p123123 --single-transaction --routines --events --set-gtid-purged=ON --all-databases >/tmp/10_2.sql# mysql </tmp/10_2.sqlmysql> CHANGE MASTER TO MASTER_HOST = ‘192.168.234.130‘, MASTER_PORT = 3306, MASTER_USER = ‘repl‘, MASTER_PASSWORD = ‘repl‘, MASTER_AUTO_POSITION = 1;mysql> start slave;
# innobackupex --defaults-file=/export/servers/mysql/etc/my.cnf --slave-info --user=root --password=123123 --no-timestamp /tmp/in.sql# cat xtrabackup_slave_infoSET GLOBAL gtid_purged=‘29bd8c99-9e4d-11e7-a072-000c29d00b2d:1-5, 59fe7a3e-9dd6-11e7-9d6c-000c29e57c69:1-68‘;CHANGE MASTER TO MASTER_AUTO_POSITION=1> reset master;> SET @@GLOBAL.GTID_PURGED=‘$gtid_dump‘; //上面备份文件中的值> change master to master_auto_position=1;
DATABASE:默认值,基于库的并行复制方式LOGICAL_CLOCK:基于组提交的并行复制方式
# mysqlbinlog -vv mysql-bin.000001 |egrep last_commit#171002 11:53:31 server id 1 end_log_pos 219 CRC32 0x4a9095a9 Anonymous_GTID last_committed=0 sequence_number=1#171002 11:53:31 server id 1 end_log_pos 473 CRC32 0x786dd106 Anonymous_GTID last_committed=1 sequence_number=2
标签:temp 概念 ever ids global inline stop 生成 evel
原文地址:http://www.cnblogs.com/jesper/p/7623939.html