]> git.donarmstrong.com Git - bin.git/commitdiff
add autoslaveskip
authorDon Armstrong <don@donarmstrong.com>
Sat, 10 Dec 2011 02:03:09 +0000 (02:03 +0000)
committerDon Armstrong <don@donarmstrong.com>
Sat, 10 Dec 2011 02:03:09 +0000 (02:03 +0000)
autoslaveskip [new file with mode: 0755]

diff --git a/autoslaveskip b/autoslaveskip
new file mode 100755 (executable)
index 0000000..be1ec87
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+while sleep 5s; do
+    echo -n $(date);
+    mysql -Be 'show slave status\G'|perl -ne 'm/(Seconds|Slave)_.+?\: (.+)\n/ && print " ".$2;';
+    echo;
+    if ! mysql -Be 'show slave status\G'|awk '/Slave_SQL_Running/{print $2}'|grep -q Yes; then
+       echo "Advancing mysql by 1";
+       mysql -Be "SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; start slave;";
+       sleep 2s;
+    fi;
+done;