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 ....'