对于 mysql 使用大页面,我需要设置一个 ulimit - 我已经在limits.conf 中做到了这一点。但是,limits.conf (pam_limits.so) 不会为 init 读入,仅适用于“真实”shell。我之前通过向 initscript 启动函数添加“ulimit -l”解决了这个问题。我需要某种可重复的方法来做到这一点,现在这些盒子是由厨师管理的,我们不想接管实际上由 RPM 拥有的文件。
我的 MongoDB 数据库在负载下遇到问题,日志中出现以下错误:
[initandlisten] pthread_create failed: errno:11 Resource temporarily unavailable
[initandlisten] can't create new thread, closing connection
Run Code Online (Sandbox Code Playgroud)
我得出的结论是,我需要提高 1024 的“ulimit -u”或“最大进程”设置,并且使用率可能已经超过了启动的 Web 前端(不知道如何检查) .
我编辑了 /etc/security/limits.conf 以添加最后两行(前两行已经存在):
* soft nofile 350000
* hard nofile 350000
* soft nproc 30000
* hard nproc 30000
Run Code Online (Sandbox Code Playgroud)
然后我重新启动了系统(顺便说一句,我应该这样做,还是重新启动 mongod 服务就足够了?)
重新启动后,查看 mongod 进程的进程限制,似乎软限制已被忽略:
$ cat /proc/2207/limits
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 8388608 …Run Code Online (Sandbox Code Playgroud) 我不断收到此错误nginx/error.log并让我发疯:
8096 worker_connections exceed open file resource limit: 1024
Run Code Online (Sandbox Code Playgroud)
我已经尝试了所有我能想到的方法,但无法弄清楚是什么限制了 nginx。你能告诉我我错过了什么吗?
nginx.conf 有这个:
worker_processes 4;
events {
worker_connections 8096;
multi_accept on;
use epoll;
}
Run Code Online (Sandbox Code Playgroud)
我security/limits.conf像这样更改了系统的 Ulimit :
# This is added for Open File Limit Increase
* hard nofile 199680
* soft nofile 65535
root hard nofile 65536
root soft nofile 32768
# This is added for Nginx User
nginx hard nofile 199680
nginx soft nofile 65535
Run Code Online (Sandbox Code Playgroud)
它仍然显示错误。所以我也尝试编辑/etc/default/nginx并添加了这一行:
ULIMIT="-n 65535"
Run Code Online (Sandbox Code Playgroud)
它仍然显示相同的错误。无法弄清楚是什么将 nginx 工作连接限制为 1024。你能指出我吗? …
我在 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) 我正在尝试为 ubuntu 机器上的所有用户提高打开文件描述符的最大值。
我已将以下几行添加到/etc/security/limits.conf:
* soft nofile 100000
* hard nofile 100000
Run Code Online (Sandbox Code Playgroud)
而且,基于这个问题,我检查了以下/etc/pam.conf设置pam_limits:
$ grep "pam_limits" /etc/pam.d/*
/etc/pam.d/atd:session required pam_limits.so
/etc/pam.d/common-session:session required pam_limits.so
/etc/pam.d/cron:session required pam_limits.so
/etc/pam.d/login:session required pam_limits.so
/etc/pam.d/sshd:session required pam_limits.so
/etc/pam.d/su:session required pam_limits.so
/etc/pam.d/sudo:session required pam_limits.so
Run Code Online (Sandbox Code Playgroud)
我的 file-max 似乎没问题:
$ cat /proc/sys/fs/file-max
762659
Run Code Online (Sandbox Code Playgroud)
然而,当我检查时,我仍然有默认的 1024 ulimit -a:
$ ulimit -a | grep files
open files (-n) 1024
Run Code Online (Sandbox Code Playgroud)
我还能检查什么?
背景:我正在监视用于为特定用户运行进程的 ulimit。(我偶尔会看到以不正确的限制开始的进程。)我问了几个自称是 Linux 专家的人,一个建议lsof -p <pid>,另一个建议ls /proc/<pid>/fd,但都没有肯定哪个更准确地反映了对最大值的实际计数进程的打开文件限制。
那么,它是哪个?
lsof -p <pid> | wc -l
Run Code Online (Sandbox Code Playgroud)
或者
ls /proc/<pid>/fd | wc -l
Run Code Online (Sandbox Code Playgroud)
请详细说明区别。谢谢!
我最近检查了我们的 redis 进程之一,以使用以下方式应用的 ulimits:
cat /proc/<redis-pid>/limits
并且惊讶地发现它处于低默认值:
Limit Soft Limit Hard Limit
Max open files 4016 4016
Run Code Online (Sandbox Code Playgroud)
我很惊讶,因为我们配置了以下内容:
# /etc/sysctl.conf
fs.file-max = 100000
Run Code Online (Sandbox Code Playgroud)
.
# /etc/security/limits.conf
* soft nofile 100000
* hard nofile 100000
Run Code Online (Sandbox Code Playgroud)
.
# /etc/ssh/sshd_config
UsePAM yes
Run Code Online (Sandbox Code Playgroud)
.
# /etc/pam.d/sshd
session required pam_limits.so
Run Code Online (Sandbox Code Playgroud)
谁能告诉我为什么增加的 ulimit 没有应用于正在运行的 redis 进程?
redis 进程以用户“redis”的身份运行,由于限制增加,服务器已重新启动。我们在 Debian Squeeze 上。
/var/log/secure:
su: pam_keyinit(su-l:session): Unable to change UID to 500 temporarily
su: pam_keyinit(su-l:session): Unable to change UID to 500 temporarily
su: pam_unix(su-l:session): session opened for user adtech by root(uid=0)
su: pam_unix(su-l:session): session closed for user adtech
Run Code Online (Sandbox Code Playgroud)
我猜这是由每个用户限制引起的,但与其他用户相比没有什么不同。
这是ulimit -n为了adtech:
[adtech@hmaster87 root]$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 192025
max locked memory (kbytes, -l) 64
max memory …Run Code Online (Sandbox Code Playgroud) 我想为 Centos 7 中的所有用户永久设置打开文件限制,但在谷歌上似乎有很多相互矛盾的信息。
Windows 有真正的 ulimit 吗?我正在寻找如何防止一个程序消耗 100% cpu 的方法/程序。
谢谢。