问题现象:

应用重启,日志里面报错too manany connections

问题分析:

线上该业务线应用全部重启,一个有38个应用,每个应用3台服务器,每台服务器启动5个链接:

num=38*3*5=570;

570<2048,我们默认的应用最大连接数是2048,怎么会报too manany connections错误。

查看配置文件/etc/my.cnf,确实是max_connections=2028;

登录数据库:

mysql> show variables like '%max%connection%';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| max_connections | 214 |
| max_user_connections | 0 |
+----------------------+-------+
2 rows in set (0.00 sec)

神奇的max_connetions 居然成了214,经排查并没有认为修改过该参数值。

[root@mysq-60-103 ~]# ps -ef|grep mysqld_safe
root 2676 1815 0 12:32 pts/0 00:00:00 grep mysqld_safe
mysql 23450 1 0 Oct10 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/mysql/data --pid-file=/mysql/data/mysql.pid

查看mysql实例启动进程,是使用mysql用户启动的,而在系统参数配置中,除mysql用户外,其它用户都限制了最大创建连接为1024.因为2048>1024

所以以mysql用户启动mysql实例时,会从默认值214开始分配,以至于max_connetions =214;

[root@mysql-zxzs-60-103 ~]# cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

* soft nproc 1024
root soft nproc unlimited

解决方式:

1、以root用户启动mysql实例;

2、向 /etc/security/limits.d/90-nproc.conf文件中追加如下参数:

mysql soft nproc 65535
mysql hard nproc 65535

使配置生效后,再已mysql用户启动mysql实例。

诡异的too manany connections报错的更多相关文章

  1. 解决:eclipse配置Database Connections报错Communications link failure Last packet sent to the server was 0 ms ago

    网上各式各样的问题,不过我的问题在于我开了Proxifier,导致链接localhost的时候被拦截...把Proxifier关了就好了 以后遇到这种问题.连不上数据库啊,连不上本地的服务器啊,先检查 ...

  2. 报错Too many connections

    com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establish ...

  3. 【JDBC 报错】Connections could not be acquired from the underlying database!

    项目启动报错: [2016-07-13 10:04:15,074] ERROR org.apache.ibatis.executor.BaseExecutor Could not get a data ...

  4. mongodb报错:connection refused because too many open connections: 819

    问题: 发现mongodb无法连接,查看mongodb日志,出现大量的如下报错: [initandlisten] connection refused because too many open co ...

  5. Mysql:报错message from server: "Too many connections"(连接太多)

    报错信息 Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source re ...

  6. hive报错 Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:For direct MetaStore DB connections,

    学习hive 使用mysql作为元数据  hive创建数据库和切换数据库都是可以的 但是创建表就是出问题 百度之后发现 是编码问题 特别记录一下~~~ 1.报错前如图: 2.在mysql数据库中执行如 ...

  7. jenkins centos slave起不来报错The SSH key presented by the remote host does not match the key saved in the Known Hosts file against this host. Connections to this host will be denied until the two keys mat

    场景:我的centos-204是一台centos的机器,本来用https://www.cnblogs.com/zndxall/p/8297356.html 的centos slave方式搭建ok的,一 ...

  8. RDS 在线DDL诡异报错ERROR 1062 (23000): Duplicate entry

    RDS上执行报错如下: MySQL [ad_billing]> ALTER TABLE ad_spending ADD COLUMN impr bigint(20) NOT NULL DEFAU ...

  9. hive 字符集问题 报错 Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:For direct MetaStore DB connections,

    学习hive 使用mysql作为元数据  hive创建数据库和切换数据库都是可以的 但是创建表就是出问题 百度之后发现 是编码问题 特别记录一下~~~ 1.报错前如图: 2.在mysql数据库中执行如 ...

随机推荐

  1. 根据 MySQL 状态优化 ---- 3. key_buffer_size

    查看 MySQL 服务器运行的各种状态值: mysql> show global status: 3. key_buffer_size key_buffer_size 是设置 MyISAM 表索 ...

  2. (转自http://www.blogjava.net/moxie/archive/2006/10/20/76375.html)WebWork深入浅出

    (转自http://www.blogjava.net/moxie/archive/2006/10/20/76375.html) WebWork深入浅出 本文发表于<开源大本营> 作者:钱安 ...

  3. Functional testing - python, selenium and django

    Functional testing  - python selenium django - Source Code : from selenium import webdriverfrom sele ...

  4. Python从题目中学习:List comprehension

    九九乘法表作业其实有更简单的做法,就是用列表推导式. ------------------------------------------------------------------------- ...

  5. PHP基础课程学习总结

    时间过得很快,不知不觉中过去了一个月,PHP基础课程已经学完了.休息这几天中,睡觉起来,整理下笔记,几天的假期又过去了,明天正式开始PHP的专业课程,新的征途又要开始了.开发整站时发现,过去整站做得太 ...

  6. C# string类型和byte[]类型相互转换

    string类型转成byte[]: byte[] byteArray = System.Text.Encoding.Default.GetBytes ( str ); byte[]转成string: ...

  7. Spark Streaming源码解读之Receiver生成全生命周期彻底研究和思考

    本期内容 : Receiver启动的方式设想 Receiver启动源码彻底分析 多个输入源输入启动,Receiver启动失败,只要我们的集群存在就希望Receiver启动成功,运行过程中基于每个Tea ...

  8. Centos下MySQL使用总结

    转载于CentOS中文站:http://www.centoscn.com/CentOS/Intermediate/2013/0817/1334.html 一.MySQL安装 Centos下安装mysq ...

  9. mysql 索引分类

    在数据库表中,对字段建立索引可以大大提高查询速度.通过善用这些索引,可以令 MySQL的查询和运行更加高效.索引是快速搜索的关键.MySQL索引的建立对于MySQL的高效运行是很重要的.下面介绍几种常 ...

  10. construction of tuples containing 0 or 1 items

    [construction of tuples containing 0 or 1 items] the syntax has some extra quirks to accommodate the ...