J P*_*ret 17 mysql ulimit max-file-descriptors file-descriptors
我在 XenServer 上运行 Ubuntu 16.04 Server,但遇到了 MySql 的打开文件限制问题。
这是我到目前为止所做的:
sudo nano /etc/security/limits.conf (参考)
* soft nofile 1024000
* hard nofile 1024000
* soft nproc 102400
* hard nproc 102400
mysql soft nofile 1024000
mysql hard nofile 1024000
Run Code Online (Sandbox Code Playgroud)
sudo nano /etc/init/mysql.conf (参考)
limit nofile 1024000 1024000
limit nproc 102400 102400
Run Code Online (Sandbox Code Playgroud)
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf (参考)
[mysqld_safe]
open_files_limit = 1024000
[mysqld]
open_files_limit = 1024000
Run Code Online (Sandbox Code Playgroud)
当上述方法不起作用时,我继续执行以下操作:
须藤纳米 /etc/sysctl.conf
fs.file-max = 1024000
Run Code Online (Sandbox Code Playgroud)
须藤纳米 /etc/pam.d/common-session
session required pam_limits.so
Run Code Online (Sandbox Code Playgroud)
须藤纳米 /etc/pam.d/common-session-noninteractive
session required pam_limits.so
Run Code Online (Sandbox Code Playgroud)
须藤纳米/lib/systemd/system/mysql.service
LimitNOFILE=infinity
LimitMEMLOCK=infinity
Run Code Online (Sandbox Code Playgroud)
当我登录我的用户帐户时,一切似乎都很好:
ulimit -Hn
1024000
ulimit -Sn
1024000
Run Code Online (Sandbox Code Playgroud)
如果我以 mysql 登录,它看起来也不错:
mysql@server:~$ ulimit -Hn
1024000
mysql@server:~$ ulimit -Sn
1024000
Run Code Online (Sandbox Code Playgroud)
但是,当我查看 proc 时:
ps -ef | grep mysql
cat /proc/1023/limits | grep open
Max open files 65536 65536 files
Run Code Online (Sandbox Code Playgroud)
或者当我在 MySql 中查看它时:
mysql> show global variables like 'open%';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| open_files_limit | 65536 |
+------------------+-------+
Run Code Online (Sandbox Code Playgroud)
从日志(/var/log/mysql/error.log):
2016-07-25T05:44:35.453668Z 0 [警告] 无法将 max_open_files 的数量增加到 65536 以上(请求:1024000)
我在这里完全没有想法。一开始我确实从 1024 处的 open_files_limit 开始,上面的一个肯定已经改变了它,但我需要它变得更高。我已经达到了这个限制,因为我有很多有时有很多分区的数据库和表。
我什至尝试过比 1024000 更不激进的数字,但没有运气。
有什么想法吗?
Jer*_*ost 28
这在 Ubuntu Xenial 16.04 上对我有用:
创建目录 /etc/systemd/system/mysql.service.d
放入/etc/systemd/system/mysql.service.d/override.conf
:
[Service]
LimitNOFILE=1024000
Run Code Online (Sandbox Code Playgroud)
现在执行
systemctl daemon-reload
systemctl restart mysql.service
Run Code Online (Sandbox Code Playgroud)
是的,LimitNOFILE=infinity
实际上似乎将其设置为 65536。
您可以通过执行以下操作在启动 MySQL 后验证上述内容:
cat /proc/$(pgrep mysql)/limits | grep files
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
13033 次 |
最近记录: |