[Warning] Buffered warning: Changed limits: max_connections: 214 (requested 2000)

1.版本

1)操作系统

 cat /etc/issue
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Kernel \r on an \m

 cat /proc/version
Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014

2)mysql数据库版本

mysql --version
mysql  Ver 14.14 Distrib 5.6.26, for linux-glibc2.5 (x86_64) using  EditLine wrapper


2.问题描述

2.1 发现问题

今天在起我的测试环境库的时候,发现error log中出现如下告警:

mysqld_safe --defaults-file=/etc/my.cnf &

2016-01-08 09:37:38 28555 [Warning] Buffered warning: Could not increase number of max_open_files to more than 1024 (request: 10240)

2016-01-08 09:37:38 28555 [Warning] Buffered warning: Changed limits: max_connections: 214 (requested 2000)

2016-01-08 09:37:38 28555 [Warning] Buffered warning: Changed limits: table_open_cache: 400 (requested 2000)
##在my.cnf文件中指定的open_files_limit=10240,max_connections指定的值为2000,table_open_cache未指定
2.2分析问题

下面我们来逐条分析一下 为什么会出现这三个告警:

2.2.1 关于max_open_files的告警

  其实只要你了解mysql关于open_files_limit设置规则(open_files_limit值并不一定为你在配置文件中指定的值哦),那么这个问题就很清楚了。至于open_files_limit设置的详细内容请参见我的另一篇博客(http://blog.csdn.net/shaochenshuo/article/details/51966076)。本篇博客仅指出问题。此处的问题是我们操作系统层面的open files限制为1024

[root@localhost ~]# ulimit -Sa|grep "open files"
open files                      (-n) 1024
[root@localhost ~]# ulimit -Ha|grep "open files"
open files                      (-n) 4096
所以此处 open_files_limit就取了操作系统open files限制的值1024

2.2.2 关于max_connections 的告警

  这个其实是mysql 5.6的一个bug,该bug详细内容请参见

https://bugs.mysql.com/bug.php?id=71821

或者

http://blog.csdn.net/shaochenshuo/article/details/50484475

   当mysql发现操作系统的 open files或者mysql配置文件中open_files_limit的值设置的比较小的时候,mysql在启动的时候会自动调整max_connections的值。但是mysql的官方文档,和上面的bug中 都没有说到 这个调整是根据什么样的规则。

2.2.3 关于table_open_cache 的告警

   该告警出现的原因同2.2.2(requested 2000 是因为 table_open_cache 的默认值是2000,因为我们在cnf文件中没有指定table_open_cache,所以取了默认值,但是又发现操作系统的open files限制太小,所以该参数自动调整为400)


3.解决方案

   调整操作系统的open files限制

vi /etc/security/limits.conf
在最后加上
*           soft   nofile       655350
*           hard   nofile       655350
*           hard   nproc        655350
*           soft   nproc        655350
或者
mysql hard nofile 655350
mysql soft nofile 655350
mysql hard nproc 655350
mysql soft nproc 655350


##参考

http://blog.csdn.net/shaochenshuo/article/details/51966076

http://blog.csdn.net/shaochenshuo/article/details/50484475


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

渔夫数据库笔记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值