今天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. [Week17] 个人阅读作业

      个人阅读作业Week17 reading buaa software   解决的问题 这是提出问题的博客链接:http://www.cnblogs.com/SivilTaram/p/4830893 ...

  2. week5-Link Layer

    Technology:Internets and Packets course Layer 1 : Link Introduction/The Link Layer moving from histo ...

  3. Beta冲刺——day6

    Beta冲刺--day6 作业链接 Beta冲刺随笔集 github地址 团队成员 031602636 许舒玲(队长) 031602237 吴杰婷 031602220 雷博浩 031602134 王龙 ...

  4. Activiti的ACT_GE_PROPERTY表初始化

    create table ACT_GE_PROPERTY ( NAME_ ), VALUE_ ), REV_ integer, primary key (NAME_) ) ENGINE=InnoDB ...

  5. Windows 设置开机自动登录

    1. 自己一些windows的虚拟机 有时候开机之后 输入用户名密码时间特别长. 需要等待很久, 如果能够设置开机自动登录的话 能够节约很多时间. 2. 最简单的办法  运行输入 control us ...

  6. hexo d 报错‘fatal: could not read Username for 'https://github.com': No error’

    问题描述 今天早上,一如往常的往在github上创建的hexo博客上传文章,结果报错 'fatal: could not read Username for 'https://github.com': ...

  7. ES6学习笔记(五):Class和Module

    Class Class 只是一个语法糖,其功能用es5也能实现,但是比es5更符合类的期待 定义: constructor代表构造方法,而this指向new 生成的实例 定义类方法时,可以不使用fun ...

  8. Python学习---------登陆系统代码实现

    题目要求: 一.编写登陆入口 1.输入用户名密码 2.认证成功后显示欢迎的信息 3.输错三次后锁定 Readme: 1.本次实现了登陆系统,若锁定就输出为锁定用户(锁定信息保存在user_lock.t ...

  9. HDU 4303 Hourai Jeweled 解题报告

    HDU 4303 Hourai Jeweled 解题报告 评测地址: http://acm.hdu.edu.cn/showproblem.php?pid=4303 评测地址: https://xoj. ...

  10. BZOJ4912 [Sdoi2017]天才黑客 【虚树 + 最短路】

    题目链接 BZOJ4912 题解 转移的代价是存在于边和边之间的 所以把边看做点,跑最短路 但是这样做需要把同一个点的所有入边和所有出边之间连边 \(O(m^2)\)的连边无法接受 需要优化建图 膜一 ...