[解决] Cannot find a valid baseurl for repo: base/7/x86_64
作者:admin 时间:2026-4-14 4:46:1 浏览:执行yum命令报错:Cannot find a valid baseurl for repo: base/7/x86_64,原因是:
镜像列表(mirrorlist)失效了。
解决方法
解决方法是更换镜像列表的域名。
这个镜像列表的文件是 CentOS-Base.repo ,文件位置在 /etc/yum.repos.d/ 这目录里。
可以用FTP等工具把该文件下载到本地,然后用记事本打开来更改文件里的镜像列表的域名。
对于 CentOS 7 系统,下面内容是一个正确的版本,你可以直接使用它。
# 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
baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://vault.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://vault.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://vault.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
文件修改完毕后,执行清理并重建缓存命令:
yum clean all
yum makecache
yum update
注意问题
注意!如果不是 CentOS 7,上面的内容也应该适用,如果无效,你只需要知道 vault.centos.org 这个域名是有效的,用它来替换原文件的镜像域名就行。
相关文章
标签: linux技术
相关文章
x



