發(fā)現(xiàn)Mysql主從不同步,找到解決方案:
mysql > stop slave;
mysql > set global sql_slave_skip_counter =1;
mysql > start slave;
但是在執(zhí)行第二步的時候報錯:
ERROR 1858 (HY000): sql_slave_skip_counter can not be set when the server is running with GTID_MODE = ON. Instead, for each transaction that you want to skip, generate an empty transaction with the same GTID as the transaction
通過分析原來是Gtid的同步方式,需要通過Gtid來修復(fù)
mysql> show slave status\G;

上圖中是表示正常的。懶的模擬環(huán)境了,比如有下列情況:
Retrieved_Gtid_Set: ffd80980-c7cb-11e9-beda-0050569051da:1-8 檢索到主已經(jīng)8個事務(wù)了。
ffd80980-c7cb-11e9-beda-0050569051da這個是表示主的UUID,唯一的
Executed_Gtid_Set: c46aebe0-c8e9-11e9-8057-005056a20520:1-135710,
ffd80980-c7cb-11e9-beda-0050569051da:1-7 表示從上已經(jīng)執(zhí)行了7個事務(wù)了。
如果是這種情況,可采用下列方法修復(fù):
mysql > stop slave;
mysql >SET GTID_NEXT=' ffd80980-c7cb-11e9-beda-0050569051da:8';
mysql > begin;commit;
mysql > SET GTID_NEXT="AUTOMATIC";
mysql > start slave;