RHEL7环境下如何让yum忽略存在解析错误的repo文件?
解决Yum仓库解析错误并移除问题RPM的方法
临时指定可用仓库路径绕过错误文件
因为没有/etc/yum.repos.d的访问权限,你可以通过--repopath参数临时指定一个仅包含正常仓库的目录,彻底避开错误的仓库文件:
- 创建临时目录:
mkdir -p ~/temp_valid_repos - 复制系统中可用的仓库文件到这个目录(如果能访问到的话),或者手动创建适配你系统版本的基础仓库文件,比如
~/temp_valid_repos/base.repo(以CentOS 7为例):[base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 - 执行移除命令时指定该路径,同时禁用所有默认仓库,只启用临时目录里的:
yum --repopath=~/temp_valid_repos --disablerepo=* --enablerepo=base remove <问题RPM的名称>
强制跳过仓库校验直接移除
如果临时仓库路径方法无效,试试通过yum的配置参数跳过仓库解析和校验环节:
- 基础强制移除命令:
yum remove <问题RPM的名称> --nogpgcheck --skip-broken - 若仍报错,添加更多跳过校验的参数:
yum remove <问题RPM的名称> --nogpgcheck --skip-broken --setopt=repo_gpgcheck=0 --setopt=skip_missing_names_on_install=False
临时屏蔽问题仓库文件
如果能从yum报错信息里定位到错误仓库文件的名称(比如broken_repo.repo),可以尝试以下方式屏蔽它:
- 部分yum版本支持
--exclude-repo-file参数,直接跳过该文件:yum remove <问题RPM的名称> --exclude-repo-file=broken_repo.repo - 若不支持该参数,创建临时yum配置文件
~/temp_yum.conf,仅包含正常仓库:[main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 # 仅加载正常仓库,替换为你能访问到的有效仓库路径 include=/path/to/valid_repo1.repo include=/path/to/valid_repo2.repo - 用临时配置文件执行移除:
YUM_CONFIG=~/temp_yum.conf yum remove <问题RPM的名称>
内容的提问来源于stack exchange,提问作者fauxanadu
相关产品推荐
相关产品推荐

