首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MySQL open_files_limit的麻烦

MySQL open_files_limit的麻烦
EN

Database Administration用户
提问于 2017-03-24 00:15:21
回答 2查看 3.6K关注 0票数 1

Ubuntu 16.04.2.MySQL 5.7.17.

在查看时,我的PHP站点在连接到MySQL时遇到致命错误。阿帕奇说

打开文件时出现资源不足24错误

好吧,有道理,我有很多交通。我读了一遍,似乎我的open_files_limit变量1,024太小了(实际上是看到5000是默认的)。

因此,在阅读了一些之后,我运行了mysql --verbose --help | less来查找我应该访问的配置文件。它给了我:

默认选项按给定顺序从下列文件读取: /etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf

但是,/etc/my.cnf~/.my.cnf并不存在。

/etc/mysql/my.cnf做到了,看起来就像这样:

代码语言:javascript
复制
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

当我将open_files_limit = 2084附加到上面的/etc/mysql/my.cnf文件时。我不能sudo service mysql start MySQL。我必须删除这一行,然后才能启动MySQL。

我唯一能找到的其他MySQL配置文件是/etc/mysql/mysql.conf.d/mysqld.cnf,我尝试在那里添加open_files_limit行并重新启动,它重新启动,但是变量没有改变。

我做错了什么?我该怎么做才能提高我的open_files_limit

更新

似乎改变值的地方是在/lib/systemd/system/mysql.service

必须添加LimitNOFILE=infinity保存,然后添加systemctl daemon-reload

有很多关于一些设置的理由的解读,以及不使用无穷大的理由。

EN

回答 2

Database Administration用户

回答已采纳

发布于 2017-03-24 02:47:24

这取决于您的db体系结构。如果在MyISAM、ARIA或Innodb的单独文件中有多个表,每个表都有文件,则需要更高的打开文件限制。如果Innodb / xtradb中的所有内容都位于一个表空间中,那么提高您的文件限制将不会有好处。

检查电流系统极限

代码语言:javascript
复制
ulimit -a

临时限值增加

代码语言:javascript
复制
ulimit -n 65535

永久更新/etc/安全/限制

mysql打开的文件限制不能超过系统限制。

代码语言:javascript
复制
* soft nofile 65535
* hard nofile 65535
票数 1
EN

Database Administration用户

发布于 2017-03-28 23:17:11

一旦您在操作系统中更改了ulimit,请更改/添加

代码语言:javascript
复制
[mysqld]
open_file_slimit = 2048

然后重新开始。

注意:它必须在[mysqld]部分的my.cnf (或任何文件)。

票数 0
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/168044

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档