Mysql:too many connect
1、问题展现
应用端登录出现Too many connections报错
检查发现mysql数据库服务端已经达到了max_connections上限
#查看最大连接数
mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 5000 |
+-----------------+-------+
1 row in set (0.04 sec)
#查看当前会话连接数
show processlist;
5000 rows in set (2.72 sec) --已经满了
2、问题处理
重启mysql的服务。重启完mysql服务后,的确mysql的session数下降了,但是很快会话数又上升到了1900。
判断并不是mysql的服务器端的会话没释放,而是application端的会话没释放。
重启application的两台服务器,mysql的会话数恢复正常。
3、结论
先来看看mysql服务器端的会话保持时间:
mysql> show variables like '%wait_timeout%';
+--------------------------+----------+
| Variable_name | Value |
+--------------------------+----------+
| innodb_lock_wait_timeout | 50 |
| lock_wait_timeout | 31536000 |
| wait_timeout | 28800 |
+--------------------------+----------+
3 rows in set (0.00 sec)
mysql> show variables like '%interactive_timeout%';
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| interactive_timeout | 28800 |
+---------------------+-------+
1 row in set (0.00 sec)
interactive_timeout:服务器关闭交互式连接前等待活动的秒数。交互式客户端定义为在mysql_real_connect()中使用CLIENT_INTERACTIVE选项的客户端。又见wait_timeout
wait_timeout:服务器关闭非交互连接之前等待活动的秒数。在线程启动时,根据全局wait_timeout值或全局interactive_timeout值初始化会话wait_timeout值,取决于客户端类型(由mysql_real_connect()的连接选项CLIENT_INTERACTIVE定义),又见interactive_timeout
如此看来,两个变量是共同控制的,那么都必须对他们进行修改了。继续深入这两个变量wait_timeout的取值范围是1-2147483(Windows),1-31536000(linux),interactive_time取值随wait_timeout变动,它们的默认值都是28800。
MySQL的系统变量由配置文件控制,当配置文件中不配置时,系统使用默认值,这个28800就是默认值。要修改就只能在配置文件里修改。Windows下在%MySQL HOME%/bin下有mysql.ini配置文件,打开后添加两个变量,赋值。
要解决这个问题:
1、Use connection pooling at client side (in MySQL Connector) to reduce the number of active connections between the client and the server.
是在客户端安装MySQL Connector
2、Improve the application design to reduce the number of active connections needed and to reduce the time the connection has to stay active.
从应用端去降低并发数,减少每个会话的保持时间
3、Increase the number of connections handled by MySQL server by adjusting max_connections (keep in mind that this consumes additional RAM and is still limited)
在mysql服务器端增加最大连接数设置,不过会消耗大量内存
建议用第二种方法。因为当前应用会话保持时间是10分钟,建议降低这个数值。
原文链接:http://blog.itpub.net/22996654/viewspace-2147815
Mysql:too many connect的更多相关文章
- navicat连接centos7上mysql:2003-Can't connect to MySQL server (10060)
问题解决步骤: 1.参考http://jingyan.baidu.com/article/95c9d20dac9040ec4f75617a.html,发现是防火墙未关闭: 2.关闭并禁止firewal ...
- MySQL:Can't connect to mysql server 10038
1.防火墙高级设置 2.入站规则,新建规则 3.选择端口 4.输入MySQL端口例如'3306' 5.允许连接 6.下一步 7.自定义规则名称和描述,完成之后重新连接即可.
- CentOS的MySQL报错:Can't connect to MySQL server
原文链接: http://www.centoscn.com/CentosBug/softbug/2015/0622/5709.html 问题描述: 使用客户端远程登录连接基于CentOS 6.5服务器 ...
- Mac端解决(含修改8.0.13版的密码):Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
1. 安装mysql但是从来没启动过,今天一启动就报错: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2 ...
- 远程登陆linux连接mysql root账号报错:2003-can't connect to MYSQL serve(转)
远程连接mysql root账号报错:2003-can't connect to MYSQL serve 1.远程连接Linux系统,登录数据库:mysql -uroot -p(密码) 2.修改roo ...
- 远程连接mysql root账号报错:2003-can't connect to MYSQL serve(转)
远程连接mysql root账号报错:2003-can't connect to MYSQL serve 1.远程连接Linux系统,登录数据库:mysql -uroot -p(密码) 2.修改roo ...
- 使用图形界面管理工具Navicat for MySQL连接Mysql数据库时提示错误:Can't connect to MySQL server (10060)
版权声明:本文为 testcs_dn(微wx笑) 原创文章,非商用自由转载-保持署名-注明出处,谢谢. https://blog.csdn.net/testcs_dn/article/details/ ...
- zabbix启动web界面提示:Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
问题 zabbix启动web界面提示: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' ( ...
- 连接Mysql提示Can’t connect to local MySQL server through socket的解决方法
mysql,mysqldump,Mysqladmin,php连接mysql服务常会提示下面错误: ERROR 2002 (HY000): Can't connect to local MySQL se ...
随机推荐
- Gradle 发布 Jar 到 Archiva 时提示不能 Overwriting released artifacts is not allowed
系统提示错误信息: Received status code 409 from server: Overwriting released artifacts is not allowed. 这是在 A ...
- 修改history记录数
在linux系统下.history命令会保存多少条命令呢?曾在一本书上说,如果注销系统,那么会将所有的历史命令都定入到~/.bash_history, 但只保留1000条命令(这个是由默认的shell ...
- AGC024E Sequence Growing Hard
题意 给出\(n\),\(m\),\(mu\),问有多少个序列组\((A_0,A_1,\dots,A_n)\)满足: 序列\(Ai\)的长度恰好为\(i\) 所有元素均在\([1,m]\) \(A_{ ...
- POJ 2486 Apple Tree ——(树型DP)
题意是给出一棵树,每个点都有一个权值,从1开始,最多走k步,问能够经过的所有的点的权值和最大是多少(每个点的权值只能被累加一次). 考虑到一个点可以经过多次,设dp状态为dp[i][j][k],i表示 ...
- JavaScript Call函数原理
call原理分析,一定要看最后的例子. 1.call使用例子 function add(c, d) { return this.a + this.b + c + d; } , b: }; consol ...
- Raspberry Pi 4B 使用OpenCV访问摄像头picamera模块
目录 1.OpenCV安装 (1)安装依赖 (2)下载OpenCV源码 (3)安装pip (4)安装Python虚拟机 (5)编译OpenCV (6)验证安装 2.使用OpenCV和Python控制摄 ...
- 走进JavaWeb技术世界4:Servlet 工作原理详解
从本篇开始,正式进入Java核心技术内容的学习,首先介绍的就是Java web应用的核心规范servlet 转自:https://www.ibm.com/developerworks/cn/java/ ...
- go语言学习笔记之数组
package main import ( "fmt" ) func main() { // Declare arrays var x[5] int //Assign value ...
- shell命令:getevent和sendevent
1.getevent 输出所有event设备的基本信息 输出格式: 设备名: 事件type 事件code 事件value 注意:这里的数字都是16进制. getevent -c 10 //输出10条信 ...
- Hibernate fetch相关
fetch=FetchType.LAZY 时,spring boot jackson 返回数据时会出错. 可配置使用Hibernate4Module 帮助解决: @Configurationpubli ...