此脚本自动跳过mysql主从1062错误!
#!/bin/sh
MYSQL=mysql
lastPos=0
while [ 1 ]; do
$MYSQL -uroot -e "show slave status\G" > /tmp/.skip
lastError=`cat /tmp/.skip|grep "Last_SQL_Errno"|awk '{print $2}'`
nowPos=`cat /tmp/.skip|grep "Exec_Master_Log_Pos"|awk '{print $2}'`
if [ $lastError -eq 1062 ]; then
$MYSQL -uroot -e "slave stop; set global sql_slave_skip_counter =1; slave start;"
echo "sleep one second"
sleep 1
fi
done
MYSQL=mysql
lastPos=0
while [ 1 ]; do
$MYSQL -uroot -e "show slave status\G" > /tmp/.skip
lastError=`cat /tmp/.skip|grep "Last_SQL_Errno"|awk '{print $2}'`
nowPos=`cat /tmp/.skip|grep "Exec_Master_Log_Pos"|awk '{print $2}'`
if [ $lastError -eq 1062 ]; then
$MYSQL -uroot -e "slave stop; set global sql_slave_skip_counter =1; slave start;"
echo "sleep one second"
sleep 1
fi
done