Home > Database > Mysql Tutorial > body text

Mysql里面执行show processlist出现很多Sleep状态的线程_MySQL

WBOY
Release: 2016-06-01 13:31:33
Original
2681 people have browsed it

bitsCN.com

Mysql里面执行show processlist出现很多Sleep状态的线程

 

由于程序设计的Bug,导致目前这个项目使用的数据库中有很多Sleep状态的线程。找了很多解决办法,还没发现最终有效的解决方案。只能临时使用如下方法:

 

编写shell文件,如killSleepProcess.sh

 

[plain] while :  do    n=`mysqladmin -uroot -p*** processlist | grep -i sleep | wc -l`    date=`date +%Y%m%d/[%H:%M:%S]`    echo $n      if [ "$n" -gt 10 ]    then      for i in `mysqladmin -uroot -p*** processlist | grep -i sleep | awk '{print $2}'`      do        mysqladmin  -uroot -p*** kill $i      done      echo "sleep is too many i killed it" >> /root/tmp/sleep.log      echo "$date : $n" >> /root/tmp/sleep.log    fi  sleep 120 #每隔120 秒 执行一次  done  
Copy after login

 

上面shell代码的结果是:将show processlist查询出的所有为Sleep状态的线程kill掉

 

 

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!