1.检查网络:尝试ping www.baidu.com是否通
2.检查dns配置:cd /etc/sysconfig/network-scripts 进入网卡配置中,检查onboot是否是yes,增加DNS1=8.8.8.8
DNS2=4.2.2.2
3.更换yum源:下载国内yum源配置文件到/etc/yum.repos.d/CentOS-Base.repo
阿里云 CentOS 7 源(推荐):
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
1
网易163 CentOS 7 源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
1
搜狐 CentOS 7 源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.sohu.com/help/CentOS7-Base-sohu.repo
1
华为云 CentOS 7 源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.myhuaweicloud.com/repo/CentOS-7.repo
1
华东理工大学 CentOS 7 源:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.ustc.edu.cn/centos/7/os/x86_64
1
清华大学 CentOS 7 源:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/
1
北京理工大学 CentOS 7 源:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.bfsu.edu.cn/centos/7/os/x86_64/
1
上海交通大学 CentOS 7 源:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://ftp.sjtu.edu.cn/centos/7/os/x86_64/
1
中国科学技术大学 CentOS 7 源:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.ustc.edu.cn/centos/7/os/x86_64/
1
兰州大学 CentOS 7 源:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirror.lzu.edu.cn/centos/7/os/x86_64/
1
以上命令选择一个就行了
原文链接:https://blog.csdn.net/weixin_54626591/article/details/138488919
4.清理yum缓存,并生成新的缓存
yum clean all
- 1
yum makecache