[MySQL FAQ]系列 -- Too many open files

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介:
错误信息如下:
.....
070813 13:10:17 [ERROR] /usr/local/mysql/bin/mysqld: Can't open file: './yejr/access.frm' (errno: 24)
070813 13:10:17 [ERROR] /usr/local/mysql/bin/mysqld: Can't open file: './yejr/accesslog.frm' (errno: 24)
......
070813 13:10:17 [ERROR] Error in accept: Too many open files
....
注意到, 系统错误代号是 24, 用 perror 来查看一下具体的错误信息是什么:
[root@yejr]# /usr/local/mysql/bin/perror 24
OS error code  24:  Too many open files
原来是打开文件太多了, 好办.用sysctl来调整一下就好了:
[root@yejr]# sysctl -w fs.file-max=43621
[root@yejr]# sysctl -a | grep fs.file-max
fs.file-max = 43621
FreeBSD 下也用sysctl来调整:
[root@yejr]# sysctl -w kern.maxfiles=123280
[root@yejr]# sysctl -a | grep kern.maxfiles
kern.maxfiles = 123280
最后, 还有最重要的一点是, 修改 mysqld 的配置文件 my.cnf, 增加如下一行:
open_files_limit = 4096 
#根据自己的情况适当调整,系统默认值是 
# max_connections*5 或 max_connections + table_cache*2
然后, 以root身份重新启动 mysqld. 在这里, 尽管 my.cnf 中指定的运行用户不是root, 一样可以以root身份来启动mysqld, 否则 open_files_limit 选项无法生效, 因为内核限制了普通用户的最多打开文件数.


本文转自叶金荣51CTO博客,原文链接:http://blog.51cto.com/imysql/308614,如需转载请自行联系原作者
相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
4月前
|
关系型数据库 MySQL 数据库连接
MySQL 1040 - Too many connections 如何解决?
【10月更文挑战第11天】MySQL 1040 - Too many connections 如何解决?
547 1
|
7月前
|
SQL 关系型数据库 MySQL
mysql too many connections 解决
mysql too many connections 解决
279 4
|
7月前
|
关系型数据库 MySQL
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file
693 2
|
8月前
|
关系型数据库 MySQL 数据库连接
mysql报错:Host‘IP地址‘ isblocked because of many connection errors;unblock with ‘mysqladmin flush-hosts‘
mysql报错:Host‘IP地址‘ isblocked because of many connection errors;unblock with ‘mysqladmin flush-hosts‘
397 1
|
9月前
|
关系型数据库 MySQL 数据库连接
用Navicat备份Mysql演示系统数据库的时候出:Too Many Connections
用Navicat备份Mysql演示系统数据库的时候出:Too Many Connections
416 0
|
9月前
|
缓存 关系型数据库 MySQL
mysql报Host is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts‘。
mysql报Host is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts‘。
307 0
|
关系型数据库 MySQL
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such
363 33
|
关系型数据库 MySQL
【XAMPP启动mysql报错】Port 3306 in use by ““C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld“……
【XAMPP启动mysql报错】Port 3306 in use by ““C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld“……
|
缓存 关系型数据库 MySQL
Mysql备份时报错:mysqldump: Got error: 1016: Can't open file: '**.fr..
Mysql备份时报错:mysqldump: Got error: 1016: Can't open file: '**.fr..
106 0
|
关系型数据库 MySQL
java202303java学习笔记第四十天mysql安装initialize specified but the data directory has files in it. Aborting
java202303java学习笔记第四十天mysql安装initialize specified but the data directory has files in it. Aborting
147 0