Batch killLocked process bitsCN.com in mysql
Batch kill Locked processes in the mysql environment
On the weekend, my colleague told a mysql server that the number of connections was full. when I logged on, I found that the number of connections was full. Shou processlist found that a large number of insert itno table_name values (xxx, xxx) are Locked. Kill them in batches.
[Root @ ~] # Mysql-ss-e "show processlist" | grep 'locked' | awk' {print "kill" $1 ";"} '> kill. SQL [root @ ~] # Mysql-uroot-ppasswd
After kill, we can find that the insert statement is increasing rapidly. in this way, we can preliminarily determine that there is a large data operation, which takes a lot of time, so we can check the connection time of the current thread.
Mysql> select * from information_schema.processlist order by time;
The SQL statements that have been connected for too long are doubtful. This makes it easy to find the cause.
BitsCN.com