MySQL Group Replication Got fatal error 1236
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/d6619309/article/details/61917089
2017-03-13T10:00:26.358681+08:00 355 [ERROR] Error reading packet from server for channel 'group_replication_recovery': The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires. (server_errno=1236)
2017-03-13T10:00:26.358720+08:00 355 [ERROR] Slave I/O for channel 'group_replication_recovery': Got fatal error 1236 from master when reading data from binary log: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.', Error_code: 1236
...
x
1
2017-03-13T10:00:26.358681+08:00 355 [ERROR] Error reading packet from server for channel 'group_replication_recovery': The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires. (server_errno=1236)
2
2017-03-13T10:00:26.358720+08:00 355 [ERROR] Slave I/O for channel 'group_replication_recovery': Got fatal error 1236 from master when reading data from binary log: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.', Error_code: 1236
3
mysqldump --all-databases --set-gtid-purged=ON --single-transaction -uroot -S"/mysql_data/data/mgrtest1/mysql_mgrtest1.sock" -P24801 -p > /mysql_data/data/mgrtest1_alldb.sql
1
1
mysqldump --all-databases --set-gtid-purged=ON --single-transaction -uroot -S"/mysql_data/data/mgrtest1/mysql_mgrtest1.sock" -P24801 -p > /mysql_data/data/mgrtest1_alldb.sql
输入密码回车后,提示:
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events.
mysqldump: Couldn't execute 'SAVEPOINT sp': The MySQL server is running with the --transaction-write-set-extraction!=OFF option so it cannot execute this statement (1290)
2
1
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events.
2
mysqldump: Couldn't execute 'SAVEPOINT sp': The MySQL server is running with the --transaction-write-set-extraction!=OFF option so it cannot execute this statement (1290)
关联到mysql bug: https://bugs.mysql.com/bug.php?id=81494
根据提示信息,当节点运行在group replication模式下,不支持savepoint,而mysqldump中需要dump出这条语句,然后dump出set @@gitd_purged=XXX 这个语句
根据mysql bug链接提供的解决步骤,在主节点上执行:
mysql> set global transaction_write_set_extraction=OFF;
ERROR 3093 (HY000): The write set algorithm cannot be changed when Group replication is running.
2
1
mysql> set global transaction_write_set_extraction=OFF;
2
ERROR 3093 (HY000): The write set algorithm cannot be changed when Group replication is running.
主节点需要关闭group_replication(此时如果有其他ONLINE从节点,选择其他ONLINE节点进行mysqldump应该是更好的选择)
若stop的是主节点,请确保其他ONLINE从节点是否需要提前从集群中解除,如果需要,先stop所有从节点,再stop主节点
mysql> stop group_replication;
Query OK, 0 rows affected (8.74 sec)
mysql> set global transaction_write_set_extraction=OFF;
Query OK, 0 rows affected (0.00 sec)
5
1
mysql> stop group_replication;
2
Query OK, 0 rows affected (8.74 sec)
3
4
mysql> set global transaction_write_set_extraction=OFF;
5
Query OK, 0 rows affected (0.00 sec)
再次执行mysqldump命令即可成功dump出数据
将dump出来的文件拷贝到从节点所在机器,登陆从节点,执行:
reset master;
source ${your_sql_file}
2
1
reset master;
2
source ${your_sql_file}
恢复主节点:
mysql> set global transaction_write_set_extraction=XXHASH64;
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL group_replication_bootstrap_group=ON;
Query OK, 0 rows affected (0.01 sec)
mysql> START GROUP_REPLICATION;
Query OK, 0 rows affected (1.06 sec)
mysql> SET GLOBAL group_replication_bootstrap_group=OFF;
Query OK, 0 rows affected (0.00 sec)
11
1
mysql> set global transaction_write_set_extraction=XXHASH64;
2
Query OK, 0 rows affected (0.00 sec)
3
4
mysql> SET GLOBAL group_replication_bootstrap_group=ON;
5
Query OK, 0 rows affected (0.01 sec)
6
7
mysql> START GROUP_REPLICATION;
8
Query OK, 0 rows affected (1.06 sec)
9
10
mysql> SET GLOBAL group_replication_bootstrap_group=OFF;
11
Query OK, 0 rows affected (0.00 sec)
最后,在从节点上执行:
start group_replication;
1
1
start group_replication;
到这里从节点应该能够正常加入了
参考
引用 http://lefred.be/content/mysql-group-replication-limitations-savepoints/,评论部分如下描述 :
Savepoints are also used when executing mysqldump with –single-transaction option.
http://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_single-transaction
That means if you want to do a consistent non blocking mysqldump on a node of the group you need to put the node out of the cluster first.
e.g.
mysql> — Put the node out of the Group Replication cluster
mysql> STOP group_replication;
mysql> SET GLOBAL transaction_write_set_extraction=OFF;
$ # Dump the entire node (instance)
$ mysqldump –all-databases –triggers –routines –events –single-transaction > /mysqldump/dump_YYYYMMDD.sql
mysql> — Bring back the node into the cluster
mysql> SET GLOBAL transaction_write_set_extraction=XXHASH64;
mysql> START group_replication;
x
1
Savepoints are also used when executing mysqldump with –single-transaction option.
2
http://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_single-transaction
3
4
That means if you want to do a consistent non blocking mysqldump on a node of the group you need to put the node out of the cluster first.
5
6
e.g.
7
mysql> — Put the node out of the Group Replication cluster
8
mysql> STOP group_replication;
9
mysql> SET GLOBAL transaction_write_set_extraction=OFF;
10
11
$ # Dump the entire node (instance)
12
$ mysqldump –all-databases –triggers –routines –events –single-transaction > /mysqldump/dump_YYYYMMDD.sql
13
14
mysql> — Bring back the node into the cluster
15
mysql> SET GLOBAL transaction_write_set_extraction=XXHASH64;
16
mysql> START group_replication;