066-生产环境su: failed to execute /bin/bash: Resource temporarily unavailable

本文介绍了一种解决Linux系统中应用账户无法登录的问题的方法。通过调整账户的进程数限制来解决问题,并详细说明了如何修改配置文件以提高进程数量限制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 事件过程:接到应用同事电话,说应用账户登陆不上去

事件解决过程:登陆机器,排查内存,磁盘问题,sshd 服务账户,切应用用户报错。

 

[root@sjdubbo4-a-szzb security]# su - vkapp
Last login: Fri Dec 15 10:15:59 CST 2017 on pts/1
su: failed to execute /bin/bash: Resource temporarily unavailable

 

编辑文件  vi /etc/security/limits.d/20-nproc.conf


# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     4096     #### 把4096改为65535    
root       soft    nproc     unlimited

 

 

/etc/security/ limits.conf的格式如下:


username|@groupname       type        resource          limit

* soft noproc 65535
* hard noproc 65535
* soft nofile 65535
* hard nofile 65535
vkapp soft noproc 65535
vkapp hard noproc 65535
vkapp soft nofile 65535
vkapp hard nofile 65535
# End of file

username|@groupname:设置需要被限制的用户名,组名前面加@和用户名区别。也可以用通配符*来做所有用户的限制。

type:有 soft,hard 和 -,soft 指的是当前系统生效的设置值。hard 表明系统中所能设定的最大值。soft 的最大值不能超过hard的值。用 – 就表明同时设置了 soft 和 hard 的值。

resource:
core – 限制内核文件的大小
date – 最大数据大小
fsize – 最大文件大小
memlock – 最大锁定内存地址空间
nofile – 打开文件的最大数目
rss – 最大持久设置大小
stack – 最大栈大小
cpu – 以分钟为单位的最多 CPU 时间
noproc – 进程的最大数目
as – 地址空间限制
maxlogins – 此用户允许登录的最大数目

要使 limits.conf 文件配置生效,必须要确保 pam_limits.so 文件被加入到启动文件中。查看 /etc/pam.d/login 文件中有:
session required /lib/security/pam_limits.so

 

ulimit   [-acdfHlmnpsStvw]    [size]

参数详解:

-H 设置硬件资源限制.
-S 设置软件资源限制.
-a 显示当前所有的资源限制.
-c size:设置core文件的最大值.单位:blocks
-d size:设置数据段的最大值.单位:kbytes
-f size:设置创建文件的最大值.单位:blocks
-l size:设置在内存中锁定进程的最大值.单位:kbytes
-m size:设置可以使用的常驻内存的最大值.单位:kbytes
-n size:设置内核可以同时打开的文件描述符的最大值.单位:n
-p size:设置管道缓冲区的最大值.单位:kbytes
-s size:设置堆栈的最大值.单位:kbytes
-t size:设置CPU使用时间的最大上限.单位:seconds
-v size:设置虚拟内存的最大值.单位:kbytes

在/etc/profile文件末尾加上如ulimit    -f    1000,这样每个会话登陆时都会生效。

 

继续切换应用账户,恢复。

如果还不行 运行 ulimit -a  查看参数,得出结论

 

转载于:https://my.oschina.net/u/3635512/blog/1586257

[root@localhost ~]# sudo yum install -y kubelet-1.23.17-0 kubeadm-1.23.17-0 kubectl-1.23.17-0 --disableexcludes=kubernetes 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to packages.cloud.google.com:443; 拒绝连接" 正在尝试其它镜像。 https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to packages.cloud.google.com:443; 拒绝连接" 正在尝试其它镜像。 https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to packages.cloud.google.com:443; 拒绝连接" 正在尝试其它镜像。 https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to packages.cloud.google.com:443; 拒绝连接" 正在尝试其它镜像。 https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to packages.cloud.google.com:443; 拒绝连接" 正在尝试其它镜像。 https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to packages.cloud.google.com:443; 拒绝连接" 正在尝试其它镜像。 https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#35 - "Encountered end of file" 正在尝试其它镜像。 One of the configured repositories failed (Kubernetes), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this: 1. Contact the upstream for the repository and get them to fix the problem. 2. Reconfigure the baseurl/etc. for the repository, to point to a working upstream. This is most often useful if you are using a newer distribution release than is supported by the repository (and the packages for the previous distribution release still work). 3. Run the command with the repository temporarily disabled yum --disablerepo=kubernetes ... 4. Disable the repository permanently, so yum won't use it by default. Yum will then just ignore the repository until you permanently enable it again or use --enablerepo for temporary usage: yum-config-manager --disable kubernetes or subscription-manager repos --disable=kubernetes 5. Configure the failing repository to be skipped, if it is unavailable. Note that yum will try to contact the repo. when it runs most commands, so will have to try and fail each time (and thus. yum will be be much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=kubernetes.skip_if_unavailable=true failure: repodata/repomd.xml from kubernetes: [Errno 256] No more mirrors to try. https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to packages.cloud.google.com:443; 拒绝连接" https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to packages.cloud.google.com:443; 拒绝连接" https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to packages.cloud.google.com:443; 拒绝连接" https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to packages.cloud.google.com:443; 拒绝连接" https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to packages.cloud.google.com:443; 拒绝连接" https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to packages.cloud.google.com:443; 拒绝连接" https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno 14] curl#35 - "Encountered end of file" [root@localhost ~]# [root@localhost ~]# # 启动 kubelet [root@localhost ~]# sudo systemctl enable kubelet Failed to execute operation: No such file or directory [root@localhost ~]# sudo systemctl start kubelet Failed to start kubelet.service: Unit not found.
最新发布
07-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值