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做到了,看起来就像这样:
#
# 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
有很多关于一些设置的理由的解读,以及不使用无穷大的理由。
发布于 2017-03-24 02:47:24
这取决于您的db体系结构。如果在MyISAM、ARIA或Innodb的单独文件中有多个表,每个表都有文件,则需要更高的打开文件限制。如果Innodb / xtradb中的所有内容都位于一个表空间中,那么提高您的文件限制将不会有好处。
检查电流系统极限
ulimit -a临时限值增加
ulimit -n 65535永久更新/etc/安全/限制
mysql打开的文件限制不能超过系统限制。
* soft nofile 65535
* hard nofile 65535发布于 2017-03-28 23:17:11
一旦您在操作系统中更改了ulimit,请更改/添加
[mysqld]
open_file_slimit = 2048然后重新开始。
注意:它必须在[mysqld]部分的my.cnf (或任何文件)。
https://dba.stackexchange.com/questions/168044
复制相似问题