问题现象:

应用重启,日志里面报错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. set JAVA_HOME in RHEL/CentOS

    3.3. Install OpenJDK on Red Hat Enterprise Linux Introduction OpenJDK is one of many Java Developmen ...

  2. 使用jna调用dll,jdk位数和dll位数的关系

    最近在学习jna,发现dll文件能能否成功调用取决于jdk位数. 32位jdk只能使用32位的dll,64位jdk只能使用64位的dll,否则位数不对应的话报的错是 "Exception i ...

  3. CentOS7服务器相关配置

    ====================查看CentOS版本==================== cat /etc/redhat-release ====================YUM更新 ...

  4. spark Mllib基本功系列编程入门之 SVM实现分类

    话不多说.直接上代码咯.欢迎交流. /** * Created by whuscalaman on 1/7/16. */import org.apache.spark.{SparkConf, Spar ...

  5. 在linux上使用交换文件扩展交换空间

    想像一种情景,当我们的Linux系统用尽交换空间时,在这种情况下,我们想要使用swap分区扩展交换空间,但在某些情况下磁盘上已经没有可用的空闲分区了,致使我们不能把它扩大. 因此,在这种情况下,我们可 ...

  6. JStrom的zk数据

    /jstorm/masterlock 用于LeaderSelector的锁. /jstorm/master get /jstorm/master localhost.localdomain:7627 ...

  7. 8.9 CSS知识点2

    4.关系选择符 包含选择符(Descendant combinator) E F  选择所有被E元素包含的F元素 <style type="text/css"> h1 ...

  8. php protobuff 使用

    http://hi.baidu.com/sing520/item/a6e98a3545fe1ef2e6bb7ad0 php 不支持uint32 不支持空结构 不支持package

  9. Jquery 生成时钟

    $(function(){ showTime(); }): function showTime () { var curtime=new Date(); $(".getDateTime&qu ...

  10. mysql操作--高级

    1.视图 2.储存过程 3.SQL编程