[root@localhost ~]# su face su: failed to execute /bin/bash: Resource temporarily unavailable

本文介绍了解决Linux系统中因资源限制导致的远程登录及su命令使用异常的问题。通过修改/etc/security/limits.d/20-nproc.conf文件中的nproc参数,将默认值从4096调整为8192,成功恢复了远程登录和su命令的正常使用。

报错的背景:

原来好好的,过了一段时间,远程不能登录,su也不能正常的使用显示的是资源受限

这个只需要去改下

[root@localhost face]# egrep -v "^$|^#" /etc/security/limits.d/20-nproc.conf

*          soft    nproc     4096

root       soft    nproc     unlimited

默认的应该是4096

我直接改成了8192

[root@localhost face]# egrep -v "^$|^#" /etc/security/limits.d/20-nproc.conf

*          soft    nproc     8192

root       soft    nproc     unlimited

然后再su

就正常了

 

[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
已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误" One of the configured repositories failed (未知), and yum doesn&#39;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=<repoid> ... 4. Disable the repository permanently, so yum won&#39;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 <repoid> or subscription-manager repos --disable=<repoid> 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=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: base/7/x86_64 [root@localhost ~]# sudo systemctl enable --now rsyslog Failed to execute operation: No such file or directory
11-13
<think>我们面对的是一个复合型问题:nslookup超时 + named服务不存在 + 启动失败 + 日志无记录。根据引用[1][2]提供的信息,我们需要系统性排查。以下是分步骤解决方案: ### 一、核心问题定位 1. **服务不存在**:`named`服务可能未安装或安装失败 2. **启动失败**:配置文件错误/端口冲突/权限问题 3. **日志无记录**:日志服务未配置/日志路径错误 ```mermaid graph LR A[问题定位] --> B[检查BIND安装] A --> C[检查服务状态] C --> D[查看启动错误] D --> E[检查配置文件] E --> F[检查端口冲突] ``` ### 二、详细解决步骤 #### 步骤1:验证BIND安装 ```bash # 检查是否安装BIND rpm -q bind || echo "未安装BIND" # 若未安装则重新安装(引用[1]隐含步骤) sudo yum install bind bind-utils -y ``` #### 步骤2:排查服务启动失败 ```bash # 强制显示启动过程(关键) systemctl status named -l --no-pager # 常见错误1:端口冲突 netstat -tulnp | grep &#39;:53 &#39; # 若存在冲突(如dnsmasq),停止冲突服务 sudo systemctl stop dnsmasq && sudo systemctl disable dnsmasq # 常见错误2:权限问题 chown named:named /var/named -R restorecon -Rv /var/named ``` #### 步骤3:检查配置文件语法 ```bash # 主配置文件检查 named-checkconf /etc/named.conf # 区域文件检查(示例) named-checkzone example.com /var/named/example.com.zone ``` #### 步骤4:启用详细日志 编辑`/etc/named.conf`: ```nginx options { ... // 增加日志级别(关键!引用[2]监控思想) directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; // [!] 新增日志配置 logging { channel default_debug { file "named.run"; severity dynamic; print-time yes; }; }; }; ``` ```bash # 重启服务查看日志 systemctl restart named journalctl -u named -n 50 --no-pager ``` ### 三、深度故障排除 #### 情况1:SELinux阻止 ```bash # 检查SELinux日志 grep named /var/log/audit/audit.log | audit2allow # 临时解决方案 setsebool -P named_write_master_zones 1 ``` #### 情况2:防火墙拦截 ```bash # 开放53端口(TCP/UDP) firewall-cmd --add-service=dns --permanent firewall-cmd --reload ``` #### 情况3:服务未注册 ```bash # 重新注册服务 systemctl daemon-reload ``` ### 四、应急解决方案 若仍无法解决,使用替代方案: ```bash # 临时使用公共DNS echo "nameserver 8.8.8.8" > /etc/resolv.conf # 测试解析 nslookup ftp.example.com ``` ### 五、长效监控配置 参考引用[2]创建监控脚本`/usr/local/bin/check_dns.sh`: ```bash #!/bin/bash if ! nslookup web.example.com 127.0.0.1 &> /dev/null; then echo "DNS服务异常! $(date)" >> /var/log/dns_monitor.log systemctl restart named fi ``` ```bash # 添加定时任务 crontab -e * * * * * /usr/local/bin/check_dns.sh ``` > **关键提示**:若所有尝试均失败,考虑重新安装BIND并恢复配置: > ```bash > sudo yum reinstall bind* -y > cp /backup/named.conf /etc/ # 从备份恢复 > ``` §§相关问题§§ 1. 如何在Linux系统中彻底卸载BIND DNS服务? 2. 如何配置DNS服务器的冗余备份? 3. 使用`netstat`命令时,哪些参数组合可以查看DNS服务端口状态? 4. 当SELinux导致服务故障时,如何永久性调整策略而不只是临时修改? </think>### 解决DNS服务无法启动与nslookup超时问题 根据引用内容[^1][^2],当出现`named`服务无法找到且启动失败时,需按以下步骤系统性排查: ```mermaid graph TD A[问题定位] --> B{服务是否存在} B -->|否| C[重新安装BIND] B -->|是| D[检查启动日志] D --> E[排查配置文件] E --> F[检查端口冲突] F --> G[验证SELinux/防火墙] ``` #### 一、验证BIND安装状态 1. **检查软件包是否存在** ```bash # 确认BIND是否安装 rpm -qa | grep -E &#39;^bind-&#39; ``` - 无输出表示未安装,需执行: ```bash sudo yum install bind bind-utils -y # 引用[1]隐含步骤 ``` 2. **检查服务单元文件** ```bash # 确认服务定义是否存在 ls /usr/lib/systemd/system/named.service systemctl list-unit-files | grep named ``` - 若缺失服务文件,重新安装后执行: ```bash sudo systemctl daemon-reload # 重新加载服务配置 ``` #### 二、诊断启动失败原因 1. **强制显示启动日志** ```bash # 显示详细启动过程(关键步骤) sudo /usr/sbin/named -g -u named -4 ``` - 观察实时输出,常见错误: - `Error: couldn&#39;t open pid file &#39;/run/named/named.pid&#39;` → 目录权限问题 ```bash sudo mkdir /run/named sudo chown named:named /run/named ``` 2. **检查核心配置文件** ```bash # 语法验证(引用[1]步骤3扩展) named-checkconf /etc/named.conf ``` - 修复后重载: ```bash sudo rndc reload ``` #### 三、解决端口冲突问题 1. **检测53端口占用** ```bash sudo ss -tulnp | grep &#39;:53&#39; ``` - 若被其他进程(如dnsmasq)占用: ```bash sudo systemctl stop dnsmasq && sudo systemctl disable dnsmasq ``` 2. **处理SELinux限制** ```bash # 检查SELinux审计日志(关键) sudo grep named /var/log/audit/audit.log | audit2why ``` - 常见修复: ```bash sudo setsebool -P named_write_master_zones 1 sudo restorecon -Rv /var/named ``` #### 四、防火墙深度配置 ```bash # 开放DNS服务(非仅端口) sudo firewall-cmd --add-service=dns --permanent sudo firewall-cmd --add-port=953/tcp --permanent # rndc控制通道 sudo firewall-cmd --reload ``` #### 五、应急解决方案 若仍无法启动,使用内存盘临时运行: ```bash sudo mkdir /run/named sudo chmod 775 /run/named sudo chgrp named /run/named sudo named -u named -c /etc/named.conf -n 1 ``` #### 六、服务状态监控 参考引用[2],创建监控脚本`/usr/local/bin/dns-monitor.sh`: ```bash #!/bin/bash if ! systemctl is-active --quiet named; then logger -t DNS "服务异常重启中..." sudo systemctl restart named echo "Subject: DNS Alert" | sendmail admin@example.com fi ``` ```bash # 添加到cron echo "* * * * * /usr/local/bin/dns-monitor.sh" | sudo crontab - ``` > **关键提示**:云环境需额外检查安全组规则,确保入站规则允许UDP/TCP 53端口。若为全新安装,建议备份后重建配置: > ```bash > sudo rm -f /etc/named.conf /etc/rndc.key > sudo yum reinstall bind* > ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值