]> andersk Git - sql.git/blobdiff - sbin/slave_skip
misc /sbin utils
[sql.git] / sbin / slave_skip
diff --git a/sbin/slave_skip b/sbin/slave_skip
new file mode 100755 (executable)
index 0000000..1d3dbde
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/python
+
+import time
+import MySQLdb as sql
+con = sql.connect('localhost','root','',unix_socket='/srv/mysql/mysql.sock')
+cur = con.cursor(sql.cursors.DictCursor)
+
+while 1:
+    cur.execute('SHOW SLAVE STATUS')
+    r = cur.fetchone()
+    if r['Slave_IO_Running'] == 'Yes' and r['Seconds_Behind_Master'] is None:
+        print 'Skipping next due to:'
+        print r['Last_Error']
+        cur.execute('SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1')
+        cur.execute('START SLAVE')
+    else:
+        time.sleep(1)
This page took 0.083575 seconds and 4 git commands to generate.