本文共 1036 字,大约阅读时间需要 3 分钟。
如果有用户test,现在需要修改此用户打开文件数限制,步骤如下:
1 修改Linux下资源使用的配置文件,添加以下参数:sudo vim /etc/security/limits.conf
test soft nproc 65534test hard nproc 65534test soft nofile 65534test hard nofile 65534
参数说明:
nproc:用户可用的最大进程数量nofile:用户可打开的最大文件总数soft即是软限制,hard是硬限制。用户可以超过soft设置的值,但一定不能超过hard 的值。一般soft比hard小test:代表用户,可以用 “*” 表示,代表所有用户2 退出当前Sehll,重新登陆,输入下面的命令即可看见参数已经发现改变:
[test@localhost ~]$ ulimit -a
core file size (blocks, -c) 0data seg size (kbytes, -d) unlimitedscheduling priority (-e) 0file size (blocks, -f) unlimitedpending signals (-i) 1821max locked memory (kbytes, -l) 64max memory size (kbytes, -m) unlimitedopen files (-n) 65534pipe size (512 bytes, -p) 8POSIX message queues (bytes, -q) 819200real-time priority (-r) 0stack size (kbytes, -s) 8192cpu time (seconds, -t) unlimitedmax user processes (-u) 65534virtual memory (kbytes, -v) unlimitedfile locks (-x) unlimited
备注:如果是root用户可以在命令行直接修改,然后把ulimit -SHn 65534追加到/etc/profile文件中,普通用户在yum update升级之后,可能无法在命令行修改,可以直接修改配置文件。
转载于:https://blog.51cto.com/zengwj1949/2120733