今天R&D所在主机出现su: cannot set user id: Resource temporarily unavailable资源不可用报错,直接通过其他机器ssh huyuh@xxx.xxx.xxx.xxx时,提示 Write failed: Broken pipe。

进行排查发现机器内存使用已经没有了,进行临时的内存回收操作:
sync ; sync 将内存数据刷新到磁盘

echo 3 > /proc/sys/vm/drop_caches 内存释放
echo 0 > /proc/sys/vm/drop_caches 默认

To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free reclaimable slab objects (includes dentries and inodes):
echo 2 > /proc/sys/vm/drop_caches
To free slab objects and pagecache:
echo 3 > /proc/sys/vm/drop_caches

同时查看用户进行数的占用,发现用户占用数量过多,而默认的用户进程数量为1024,所以就出现上面的问题,经过调优以后,再通过su - huyuh正常。

1、/etc/profile
首先去查看了下/etc/profile文件,也有如下的ulimit配置:
ulimit -S -c 0 > /dev/null 2>&1
ulimit -HSn 65000
ulimit -u 65000
注:后面的-u参数为最大进程数,如果害怕其他用户通过fork死循环耗完本机资源,可以适当减少该值。默认该值为1024 。

2、/etc/security/limits.conf(此处设置,/etc/profile可不用设置)
接着看/etc/security/limits.conf 文件,发现其下面已新增了nofile的值 ,如下:

huyuh soft nproc 65535
huyuh hard nproc 65535
* soft nofile 65535
* hard nofile 65535

注:limits.conf文件实际上就是ulimit命令的配置文件。nproc为打开的最大进程数,nofile为打开的最大文件数。该处和上面的/etc/profile是重复设置的。实现上该处增加了以后,/etc/profile就不用再做配置的,而且该处配置更规范些,可以对用户进行限制。

3、/etc/security/limits.d/90-nproc.conf

即然以上两处都做了设置,还是有上面的提示,神奇了。后来又乱折腾了半天,突然想到之前在centos 6.3版本配置的时候,发现centos 6.X以后新增了一个/etc/security/limits.d/90-nproc.conf 文件,用于控制nproc 。这里面的默认配置是

* soft nproc 1024
root soft nproc unlimited
1024大小显然对我运行程序的单个开发用户来说,太少了点。更改为65535后,再su - huyuh时,问题解决完成。

转自

su: cannot set user id: Resource temporarily unavailable - Linux系统教程
http://www.linuxdiyf.com/linux/17096.html

su: cannot set user id: Resource temporarily unavailable【转】的更多相关文章

  1. su: cannot set user id: Resource temporarily unavailable

    今天R&D所在主机出现su: cannot set user id: Resource temporarily unavailable资源不可用报错,直接通过其他机器ssh huyuh@xxx ...

  2. “su: cannot set user id: Resource temporarily unavailable”处理及limits.conf说明

    一.背景介绍及问题处理 应用报账号不能ssh到主机,首先怀疑是防火墙或hosts.deny限制但查看之下并没有:接着使用其提供的账号密码确实不能登录,怀疑是密码被修改(有个和平时不太一样现像是输入密码 ...

  3. su: cannot set user id: Resource temporarily unavailable问题解决

    操作环境 SuSE11sp1 问题现象 执行su - test命令切换失败,提示"su: cannot set user id: Resource temporarily unavailab ...

  4. su切换用户报错cannot set user id: Resource temporarily unavailable

    su: cannot set user id: 资源暂时不可用   登录root su - tomcat 报错: cannot set user id: Resource temporarily un ...

  5. ssh连接报错Write failed: Broken pipe Resource temporarily unavailable

    问题描述 使用root连接服务器正常,切换普通用户连接报错 具体报错如下:Write failed: Broken pipe 或者:failed to execute /bin/bash: Resou ...

  6. error=11, Resource temporarily unavailable

    问题1:Cannot run program "/bin/ls": error=11, Resource temporarily unavailable 1 15/04/22 14 ...

  7. -bash: fork: retry: Resource temporarily unavailable;centos6.5

    Last login: Wed Jun 18 14:04:11 2014 from 1.1.1.135 -bash: fork: retry: Resource temporarily unavail ...

  8. failed to execute /bin/bash: Resource temporarily unavailable的问题处理

    [admin@localhost ~]$ sudo su - scloanLast login: Tue Jun 12 14:06:31 CST 2018 on pts/3su: failed to ...

  9. -bash: fork: retry: Resource temporarily unavailable

    登陆不了服务器The server refused to start a shell. 登陆服务器后执行ls命令报错:   1 2 $ls -bash: fork: retry: Resource t ...

随机推荐

  1. java调用不了你本以为有的方法的问题

    大部分是因为你的jar版本不对引起的,我就试过

  2. Team抢救最后一下

    Team抢救最后一下 Task1:Team抢救的总结 秦玉:       非常荣幸能以团队的方式获得这次的小黄衫,这件衣服的意义不仅是这门课的奖励,也会是我们整个抢救团队的一个见证和回忆~       ...

  3. Torch,Tensorflow使用: Ubuntu14.04(x64)+ CUDA8.0 安装 Torch和Tensorflow

    系统配置: Ubuntu14.04(x64) CUDA8.0 cudnn-8.0-linux-x64-v5.1.tgz(Tensorflow依赖) Anaconda 1. Torch安装 Torch是 ...

  4. sleep,yield,join,notify,wait,notifyAll区别

    1.  Thread.sleep(long) 和Thread.yield()都是Thread类的静态方法,在调用的时候都是Thread.sleep(long)/Thread.yield()的方式进行调 ...

  5. C# 登录窗口的设计技巧

    记得很久之前要用C#做个需要登录的小东西,自己之前完全没有编写WinForm的经验,整个过程中,自己感觉应该怎么写就怎么写,时常导致许多逻辑性的错误,比如在做这个登录窗口的时候,应该实现的效果是,用户 ...

  6. ANSI C 常见宏的使用

    1. __VA_ARGS__: ...  表示可变参数列表,__VA_ARGS__在预处理中会被可变参数列表替代 2. __FILE__:正在编译文件的文件路径 3. __LINE__:正在编译文件的 ...

  7. BZOJ 2648 / 2716 K-D Tree 模板题

    #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> # ...

  8. Problem B: 专家系统 解题报告

    Problem B: 专家系统 Description 一个专家系统是指,你雇佣了\(n\)个专家,他们每个人会做出一个结果,然后你从中选取较多的专家的结果组合而成最终的结果.专家系统广泛应用于传统机 ...

  9. Redis在window上安装

    转:https://www.cnblogs.com/M-LittleBird/p/5902850.html 在windows上启动RabbitMQ: 这是Redis的启动,需要制定配置文件,否则连接不 ...

  10. python XML梳理

    导入ElementTree模块 import xml.etree.ElementTree as ET 为了创建一个element实例,使用Element 构造函数或者SubElement()工厂函数. ...