centos操作体系运行yum命令是出现如下报错:
解决办法:
由于CentOS的源地址内容已移除,CentOS 操作体系结束了生命周期,源地址内容已移除。
只需要将它的base源换成其他可用源,我这里将它换成了阿里的base源
备份原来的源:
- mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
复制代码 执行如下命令安装新的源:
- wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
复制代码 重新执行yum相关命令,就可以正常使用了。
若显示wget命令不存在
需手动替换CentOS-Base.repo这个文件,替换成如下内容,发起直接复制粘贴替换原文件的内容,cat写入可能不生效:
- # CentOS-Base.repo
- #
- # The mirror system uses the connecting IP address of the client and the
- # update status of each mirror to pick mirrors that are updated to and
- # geographically close to the client. You should use this for CentOS updates
- # unless you are manually picking other mirrors.
- #
- # If the mirrorlist= does not work for you, as a fall back you can try the
- # remarked out baseurl= line instead.
- #
- #
-
- [base]
- name=CentOS-$releasever - Base - mirrors.aliyun.com
- failovermethod=priority
- baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
- http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
- http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
- gpgcheck=1
- gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
-
- #released updates
- [updates]
- name=CentOS-$releasever - Updates - mirrors.aliyun.com
- failovermethod=priority
- baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
- http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
- http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
- gpgcheck=1
- gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
-
- #additional packages that may be useful
- [extras]
- name=CentOS-$releasever - Extras - mirrors.aliyun.com
- failovermethod=priority
- baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
- http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
- http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
- gpgcheck=1
- gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
-
- #additional packages that extend functionality of existing packages
- [centosplus]
- name=CentOS-$releasever - Plus - mirrors.aliyun.com
- failovermethod=priority
- baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
- http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
- http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
- gpgcheck=1
- enabled=0
- gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
-
- #contrib - packages by Centos Users
- [contrib]
- name=CentOS-$releasever - Contrib - mirrors.aliyun.com
- failovermethod=priority
- baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
- http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
- http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
- gpgcheck=1
- enabled=0
- gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
复制代码 末了执行如下命令完成:
- yum clean all
- yum makecacahe
复制代码 删除其他库
若还是无法运行yum ,检察base是否存在任何本地存储库或任何其他媒体存储库,如有别的的先删除其他的,命令:
删除CentOS7-Base-163.repo这个base源:
- rm -rf /etc/yum.repos.d/CentOS7-Base-163.repo
复制代码 再次运行如下命令:
- yum clean all
- yum makecacahe
复制代码 希望对你有资助,若遇到其他环境请留言,我看到了会第一时间回复。
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |