Cannot find a valid baseurl for repo: base/7/x86_64
Centos更新或者下载无法更新报错解决办法:(如图)
解决办法:
1. 对centos进行换源:
国内推荐换成:阿里源或者清华源
阿里源网址:https://developer.aliyun.com/mirror/centos
清华源网址:https://mirror.tuna.tsinghua.edu.cn/help/centos/
以上网址都有换源的教程,我就以阿里源举例换源过程:
备份源码:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
更新软件包缓存
sudo yum makecache
换源后再次执行更新或者下载命令,查看是否解决
如果还是没法更新或者下载:
ping www.baidu.com ##测试以下是否可以ping通外网
如果无法ping通可以查看/etc/sysconfig/network-scripts目录/下的ifcfg-ens33文件:
sudo vim /etc/sysconfig/network-scripts/ifcfg-ens33
将ONBOOT="no"改为yes,(如图)
最后重启network:
sudo service network restart
再次执行更新或者下载命令,查看是否解决,到此基本可以解决