Yum 在 Linux 中的错误代码与含义
说明
常见错误代码与含义
| 错误代码/场景 | 含义 | 快速处理 |
|---|---|---|
| [Errno 14] PYCURL ERROR 6 - Couldn’t resolve host | DNS 解析失败,无法解析仓库域名 | 检查 /etc/resolv.conf 的 nameserver;测试解析(如 nslookup mirrors.aliyun.com);必要时更换为可用 DNS(如 8.8.8.8) |
| [Errno 14] PYCURL ERROR 7 - Failed to connect to host:port | 连接被拒绝/端口不通,常见于防火墙或目标服务未监听 | 测试连通(curl -v http://mirror/repodata/repomd.xml);检查 firewalld/iptables 是否放行 HTTP/HTTPS;确认仓库服务可用 |
| [Errno 12] Timeout | 下载超时 | 在 /etc/yum.conf 增加 timeout=300;更换更快镜像;检查网络质量 |
| [Errno 256] No more mirrors to try / All mirrors were tried and failed | 所有镜像均不可用 | 更换镜像源;清理缓存 yum clean all && yum makecache;检查网络与仓库配置 |
| Error: Cannot retrieve repository metadata (repomd.xml) | 仓库元数据不可达或配置错误 | 校验 /etc/yum.repos.d/*.repo 中 baseurl/mirrorlist;yum clean all && yum makecache |
| Error: Cannot find a valid baseurl for repo: base | 仓库 URL 无效或失效 | 修正 baseurl;替换为有效镜像;确认网络可达 |
| Error: Package |
仓库中不存在该包 | yum search <name> 确认包名;启用包含该包的仓库;必要时添加第三方源 |
| Error: Package |
依赖未满足 | yum deplist <name> 查看依赖;先安装缺失依赖;必要时启用提供依赖的仓库 |
| Transaction check error / file conflicts | 文件或包冲突 | 卸载冲突包(yum remove <conflict>);或临时 yum update --skip-broken(随后仍需根治冲突) |
| Another app is currently holding the yum lock | Yum 锁被占用 | 检查并结束残留进程(`ps -ef |
| Error: YUM plugin “fastestmirror” is disabled | fastestmirror 插件被禁用(可能导致选镜慢) | 在插件配置中启用 enabled=1;或命令行临时启用所需仓库 |
| Error: Repository |
仓库重复定义 | 清理 /etc/yum.repos.d/ 中的重复条目 |
| Error: Unable to read consumer identity | 订阅/授权信息不可读(常见于 RHEL 订阅管理) | 检查 /root/.yum 权限与内容;确认系统已正确注册与绑定订阅 |
| /usr/bin/python: bad interpreter: No such file or directory | Python 解释器路径错误(如 CentOS 7 上 Python 2.7 缺失) | 确认 /usr/bin/python2.7 存在;建立软链 ln -sf /usr/bin/python2.7 /usr/bin/python |
| Public key for … is not installed / Package signature verification failed | GPG 签名校验失败,常与系统时间偏差有关 | 校准时间(date;ntpdate pool.ntp.org;启用 ntpd 或 chronyd) |
| yum: cannot create directory /var/cache/yum: Read-only file system | 根分区只读 | 检查挂载:`mount |
| ImportError: No module named yum | Python 模块缺失/损坏 | 重新安装 yum:yum reinstall yum |
| Permission denied | 权限不足 | 使用 sudo 或以 root 执行;检查目标目录权限 |
通用排查步骤
yum clean all && yum makecache。yum deplist、yum provides 定位依赖;对冲突包按影响评估卸载或替代。注意事项