CentOS 6.x资源不可用解决办法

2025-10-20 14:32:15

1、用root用户登录,su - user时提示su: cannot set user id: Resource temporarily unavailable,无法进行切换用户,检查cat /etc/security/limits.conf  

*        soft    nofile 32768 *        hard    nofile 65536*        soft    nproc unlimited*        hard    nproc unlimited* hard core unlimited* soft core unlimited

没有问题 

检查系统核心参数cat /etc/sysctl.conf  也没有发现问题

2、接着检查

用root用户登录 执行ulimit -a

core file size          (blocks, -c) unlimiteddata seg size           (kbytes, -d) unlimitedscheduling priority             (-e) 0file size               (blocks, -f) unlimitedpending signals                 (-i) 1032143max locked memory       (kbytes, -l) 64max memory size         (kbytes, -m) unlimitedopen files                      (-n) 32768pipe size            (512 bytes, -p) 8POSIX message queues     (bytes, -q) 819200real-time priority              (-r) 0stack size              (kbytes, -s) 10240cpu time               (seconds, -t) unlimitedmax user processes              (-u) unlimitedvirtual memory          (kbytes, -v) unlimitedfile locks                      (-x) unlimited

也没有问题

执行ps -ef | grep -v grep | grep username | wc -l

和 lsof| grep -v grep | grep username | wc -l 发现数字都不大  没有超出限制

top一下  各项都正常

3、无奈   ps -ef | grep username kill -9 pid 干掉一些用户进程,临时登陆进来  执行ulimit -a  发现 max user processes是1024  我晕  怎么没改掉 root用户是没问题的

4、最后在/etc/security/发现有limits.d个目录,好奇之下进去看到有个名为90-nproc.conf的文件 cat一看

# Default limit for number of user's processes to prevent# accidental fork bombs.# See rhbz #432903 for reasoning. *          soft    nproc     1024root       soft    nproc     unlimited

呵呵  问题找到了  原来在这里有限制  把那行注释掉重新登陆就可以了

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢