Ubuntu 16.04服务器MySql open_file_limit不会高于65536

我在XenServer上运行Ubuntu 16.04服务器,我遇到了 MySql的打开文件限制问题.

这是我到目前为止所做的:

sudo nano /etc/security/limits.conf (reference)

* soft nofile 1024000
* hard nofile 1024000
* soft nproc 102400
* hard nproc 102400
MysqL soft nofile 1024000
MysqL hard nofile 1024000

sudo nano /etc/init/MysqL.conf (reference)

limit nofile 1024000 1024000
limit nproc 102400 102400

sudo nano /etc/MysqL/MysqL.conf.d/MysqLd.cnf (reference)

[MysqLd_safe]
open_files_limit = 1024000


[MysqLd]
open_files_limit = 1024000

当上述方法不起作用时,我接着进行了以下操作:

sudo nano /etc/sysctl.conf

fs.file-max = 1024000

sudo nano /etc/pam.d/common-session

session required pam_limits.so

sudo nano /etc/pam.d/common-session-noninteractive

session required pam_limits.so

sudo nano /lib/systemd/system/MysqL.service

LimitNOFILE=infinity
LimitMEmlock=infinity

当我登录我的用户帐户时,一切似乎都很好:

ulimit -Hn
1024000
ulimit -Sn
1024000

如果我以MysqL身份登录,它看起来也很好:

MysqL@server:~$ulimit -Hn
1024000
MysqL@server:~$ulimit -Sn
1024000

但是,当我看到proc时:

ps -ef | grep MysqL
cat /proc/1023/limits | grep open
Max open files  65536 65536 files

或者当我在MysqL中查看它时:

MysqL> show global variables like 'open%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| open_files_limit | 65536 |
+------------------+-------+

从日志(/var/log/MysqL/error.log):

2016-07-25T05:44:35.453668Z 0 [警告]无法将max_open_files的数量增加到65536以上(请求:1024000)

我完全没有想法.一开始我确实以1024的open_files_limit开始,上面的一个必须改变它,但我需要它更高.我已经达到了这个限制,因为我有很多数据库和表,有时会有很多分区.

我甚至尝试过比1024000更不积极的数字,没有运气.

有什么想法吗?

这在Ubuntu Xenial 16.04上对我有用:

创建目录/etc/systemd/system/MysqL.service.d

放入/etc/systemd/system/MysqL.service.d/override.conf:

[Service]
LimitNOFILE=1024000

现在执行

systemctl daemon-reload
systemctl restart MysqL.service

确实如此,LimitNOFILE = infinity实际上似乎将其设置为65536.

您可以通过以下操作在启动MysqL后验证以上内容

cat /proc/$(pgrep MysqL)/limits | grep files

相关文章

目录前言一、创建Hadoop用户二、更新apt和安装Vim编辑器三、...
原文连接:https://www.cnblogs.com/yasmi/p/5192694.html ...
电脑重启后,打开VirtualBox,发现一直用的虚拟机莫名的消失...
参见:https://blog.csdn.net/weixin_38883338/article/deta...
Ubuntu 18.04 LTS 已切换到 Netplan 来配置网络接口。Netpla...
介绍每个 Web 服务都可以通过特定的 URL 在 Internet 上访问...