1、查看当前yum源
sudo yum repolist
2、备份原始yum源
cd /etc/yum.repos.d
cp CentOS-Base.repo CentOS-Base.repo-20220705.bak
3、配置CentOS的DNS:
vim /etc/resolv.conf
nameserver 114.114.114.114 //国内dns
nameserver 8.8.8.8 //国外dns
4、下载yum文件,替代原始yum源:
(1)网易yum源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
yum clean all //清除缓存
yum makecache //生成缓存
解析:wget -o,使用“-o”参数来指定一个文件名
(2)阿里云yum源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
此处可作为参考
https://developer.aliyun.com/mirror/