可以看到Executed_Gtid_Set里面多了一个 4f65e570-7b32-11e2-a0de-00241db92e69:1
考虑如何进行恢复。
比较靠谱的办法是不操作主服务器, 导出从服务器green的数据,然后再导入blue中。
green:
MySQL [localhost] {msandbox} (test) > stop slave; mysql [localhost] {msandbox} (test) > FLUSH TABLES WITH READ LOCK; Query OK, 0 ROWS affected (0.00 sec) |
从green导出数据,端口是5612
[root@H209 msb_5_6_10_b]# /home/modify/mysql/5.6.10/bin/mysqldump -uroot -p -h127.0.0.1 -P5612 --all-databases --triggers --routines --events >all.sql Enter password: [root@H209 msb_5_6_10_b]# |
green:
mysql [localhost] {msandbox} (test) > UNLOCK TABLES; Query OK, 0 ROWS affected (0.00 sec) mysql [localhost] {msandbox} (test) > START slave; |
把数据导入blue,端口为5611
[root@H209 msb_5_6_10_b]# /home/modify/mysql/5.6.10/bin/mysql -uroot -p -h127.0.0.1 -P5611 < all.sql Enter password: ERROR 1840 (HY000) at line 24: GTID_PURGED can only be set when GTID_EXECUTED is empty. |
额…出错了..
all.sql:
21 -- GTID state at the beginning of the backup 22 -- 23 24 SET @@GLOBAL.GTID_PURGED='05b47d41-7b10-11e2-9fff-00241db92e69:1-19'; 25 |
blue:
mysql [localhost] {msandbox} (test) > SHOW global VARIABLES LIKE '%GTID%'; +--------------------------+-----------------------------------------------------------------------------------+ | Variable_name | VALUE | +--------------------------+-----------------------------------------------------------------------------------+ | enforce_gtid_consistency | ON | | gtid_executed | 05b47d41-7b10-11e2-9fff-00241db92e69:1-19, 4f65e570-7b32-11e2-a0de-00241db92e69:1 | | gtid_mode | ON | | gtid_owned | | | gtid_purged | 05b47d41-7b10-11e2-9fff-00241db92e69:1-15 | +--------------------------+-----------------------------------------------------------------------------------+ 5 ROWS IN SET (0.00 sec) |
确实gtid_executed非空。
blue:
mysql [localhost] {msandbox} (test) > SET global gtid_executed=''; ERROR 1238 (HY000): Variable 'gtid_executed' IS a READ ONLY variable |
这里困扰了我很久…
翻了文档才找到办法:
gtid_executed: WHEN used WITH global scope, this variable contains a representation OF the SET OF ALL transactions that are logged IN the BINARY log. WHEN used WITH SESSION scope, it contains a representation OF the SET OF transactions that are written TO the cache IN the CURRENT SESSION. Issuing RESET MASTER causes the global VALUE (but NOT the SESSION VALUE) OF this variable TO be reset TO an empty string. |
需要reset master.
blue:
mysql [localhost] {msandbox} (test) > reset master; Query OK, 0 ROWS affected (0.00 sec) |
继续把数据导入blue,端口为5611
[root@H209 msb_5_6_10_b]# /home/modify/mysql/5.6.10/bin/mysql -uroot -p -h127.0.0.1 -P5611 < all.sql Enter password: [root@H209 msb_5_6_10_b]# |
继续复制:
blue
mysql [localhost] {msandbox} (test) > START slave; Query OK, 0 ROWS affected, 1 warning (0.01 sec) |
在slave上面做reset master…看起来比较怪异,但很管用。
