今天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. 《实时控制软件设计》之Automation Studio开发环境

    Automation Studio是贝加莱公司的控制软件开发平台,软件可运行在贝加莱的基于PC的控制器上,基于Automation Studio我们可构建一个完整的控制软件构建.测试和仿真运行平台.本 ...

  2. 第二个Sprint计划

    第一个Sprint计划已完成基本框架,接着第二个计划 时间:5月30-6月3日 目标:能够将各个框架连接起来,实现基本功能,并查看数据库连接. 分工:杜殷浩:查看数据库连接,创建数据库. 何广强:实现 ...

  3. Manjaro Linux 没有声音

    在Multimedia中的PulseAudio Volume Control中的设置可以解决

  4. 编码用命令行执行的C语言词语统计程序

    需求介绍 程序处理用户需求的模式为: wc.exe [parameter][filename] 在[parameter]中,用户通过输入参数与程序交互,需实现的功能如下: 1.基本功能 支持 -c   ...

  5. [转载]Docker 完全指南

    Docker 完全指南 原作者地址: https://wdxtub.com/2017/05/01/docker-guide/  发表于 2017-05-01 |  更新于 2017-08-03 |   ...

  6. jQuery3 slim版本和普通版本区别,如何选择?

    区别概述: slim即简化版,比普通版本缺少Ajax和特效模块模块. 官方发布地址:http://blog.jquery.com/2017/03/20/jquery-3-2-1-now-availab ...

  7. BZOJ2655 calc(动态规划+拉格朗日插值法)

    考虑暴力dp:f[i][j]表示i个数值域1~j时的答案.考虑使其值域++,则有f[i][j]=f[i][j-1]+f[i-1][j-1]*i*j,边界f[i][i]=i!*i!. 注意到值域很大,考 ...

  8. python netifaces usage

    1. install python dev sudo apt-get install python-dev 2.download src code and install https://pypi.p ...

  9. Cat VS Dog HDU - 3829 (最大独立集 )

    Cat VS Dog Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others)Total ...

  10. 杭高OI20190125 (genies出题)

    /* 当一个人先从自己的内心开始奋斗,他就开始迈向了成功 ——genies (朝阳的二愣子) */ HGOI寒假赛第一场,欢迎来自各种学校的各式各样的巨老233333 感觉自己好渺小.还是NOIP ( ...