Too many connection故障处理:
原因:
max_connections 这个参数据设置的小 (默认为150,早期的时候是100,后来改成150了)
查参数的值:
show variables like "%max_connections%";
max_user_connections 用户最大连接数 这个最好要比max_connections要小
解决方法:(执行后不用重启)
gdb -p $(cat /path/data/xxx.pid) -ex "set max_connections=5000" -batch
gdb -p `pidof mysqld` -ex "set max_connections=5000" -batch
如果直接执行可能会把数据库拖垮,因为报错之前可能已经是瓶颈了
所以要先把mysql的并发调小:
innodb_thread_concurrency =0 (默认为0),把这个改小,修改成cpu的核心
set global innodb_thread_concurrency=16
然后再执行:(用哪个都行)
gdb -p $(cat /path/data/xxx.pid) -ex "set max_connections=5000" -batch
gdb -p `pidof mysqld` -ex "set max_connections=5000" -batch
解决了问题后,分析问题怎么产生的?
这些连接是从哪里来的
show processlist
mysql -uroot -p -h127.0.0.1 -A -P3306 -e "show processlist"|awk '{ if($2!="User" && $2!="user"){a[$2]=a[$2]+1}}END{for (b in a){print a[b]"\t"b}}'|sort -n -k1
或着
select count(*), substring_index(host,":",1) ip,db from information_schema.processlist group by ip, db;
查看哪些连接连3306端口
netstat -nal |grep “:3306”|awk ‘{print $5}’|awk -F‘:’ ‘{print $1}’|sort |uniq -c|sort –nr
netstat -nalp |grep "3306"
ps axu |grep 10675
针对连接数too many connection 是不是可以把这个ip给封了
用
tcpkill
tcpkill -i eth0 port 3306 and src 192.168.1.200
这些ip或进程怎么来的?
是不是
MySQL死锁 or 并发度太高造成的????????
mysql性能测试工具:
tpcc-mysql
转载于:https://blog.51cto.com/hans925/1622361