MySQL GTID 主从修复

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

解决从服务器主服务器不同步

  1. 主库 备份相应的库
# mysqldump -uroot -p xxx > xxx.sql
  1. 从库 停止掉slave进城并恢复最新的备份
mysql> stop slave;
mysql> source xxx.sql;

错误:

Slave_IO_Running:No
Slave_SQL_Running:Yes
Last_IO_Error:Got fatal error1236from 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.'

解决:

  1. 主库 注意 GTID_EXECUTED
master>show global variables like 'GTID_EXECUTED';
+---------------+-------------------------------------------+
|Variable_name|Value|
+---------------+-------------------------------------------+
|gtid_executed|9a511b7b-7059-11e2-9a24-08002762b8af:1-14|
+---------------+-------------------------------------------+
  1. 从库 注意 GTID_PURGED
slave1>reset master;
slave1>show global variables like 'GTID_EXECUTED';
+---------------+-------+
|Variable_name|Value|
+---------------+-------+
|gtid_executed||
+---------------+-------+
slave1>set global GTID_PURGED="9a511b7b-7059-11e2-9a24-08002762b8af:1-14";
slave1>start slave;
slave1>show slave status\G
[...]
Slave_IO_Running:Yes
Slave_SQL_Running:Yes
[...]
  • 参考 https://www.percona.com/blog/2013/02/08/how-to-createrestore-a-slave-using-gtid-replication-in-mysql-5-6/

转载于:https://my.oschina.net/firxiao/blog/2992521

你可能感兴趣的:(数据库,python)