运行后即进入死循环,每隔一秒执行一次,清理几种经常引起负载高的sql。使用完毕后按ctrl+c退出
#!/bin/bash
i=2
while(($i > 1))
do
mysql -uroot -p'xxx' -S /data/mysqldata/3306/mysql.sock -e "show processlist;"|grep -E "Send|Copying|Creating|Sorting" > /tmp/locked.txt #grep里的类型可根据自己情况修改
awk '{print "kill",$1,";"}' /tmp/locked.txt > /tmp/kill_lock.sql
mysql -uroot -p'xxx' -S /data/mysqldata/3306/mysql.sock sleep 1 #每隔一秒执行一次,可根据自己情况修改
done
#!/bin/bash
i=2
while(($i > 1))
do
mysql -uroot -p'xxx' -S /data/mysqldata/3306/mysql.sock -e "show processlist;"|grep -E "Send|Copying|Creating|Sorting" > /tmp/locked.txt #grep里的类型可根据自己情况修改
awk '{print "kill",$1,";"}' /tmp/locked.txt > /tmp/kill_lock.sql
mysql -uroot -p'xxx' -S /data/mysqldata/3306/mysql.sock sleep 1 #每隔一秒执行一次,可根据自己情况修改
done