mysql 主從從M-S1-S11 ,S1資料庫15張表的資料被刪除掉了幾千行
阿新 • • 發佈:2019-02-03
3層主-從-從從
從裡面15張表被有計劃的刪除了幾千行資料,共15張表致中,同事意外乾的,導致主從中斷。主庫更新頻繁,要求其中被刪掉資料在所有資料庫中都刪掉,主庫中所有的更新全部都同步的到後面的從庫中去,因是資料採集類的該15張表要求一致性不嚴格。
所以偷懶解決
1.跳過主從複製中的錯誤
2.停掉爬蟲更新程式
3.從dump15張表,寫入主
1. 跳過主從複製中的錯誤的指令碼
#!/usr/bin/python # -*- coding: UTF-8 -*- import pymysql import time ip53="10.18.141.53" # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # mydb53 = pymysql.connect(ip53,"dba","dba.","crdw" ) mycursor53 = mydb53.cursor() mycursor53.execute('SET CHARACTER SET utf8;') mycursor53.execute('SET NAMES utf8;') mycursor53.execute('SET character_set_connection=utf8;') Slave_SQL_Running53 = '' for i in range(1,180000): time.sleep(1) mycursor53.execute('show slave status') results = mycursor53.fetchall() for row in results: Slave_IO_Running53 = row[10] Slave_SQL_Running53 = row[11] Last_IO_Errno53 = row[34] Last_IO_Error53 = row[35] Last_SQL_Errno53 = row[36] Last_SQL_Error53 = row[37] if(Slave_SQL_Running53 == 'No' and Slave_IO_Running53 == 'Yes' ) : Esql = ''' STOP SLAVE; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; START SLAVE;''' mycursor53.execute(Esql) print 'times:' ,i print Last_IO_Errno53 print Last_IO_Error53 print Last_SQL_Errno53 print Last_SQL_Error53 time.sleep(0.1) mydb53.close() print 'please check again ....'