centos更换国内yum下载源
1.前提,可以ping通百度
先下载wget工具,可能有点慢
sh
yum install -y wget
2.备份原来的下载源
sh
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
3.更换源
3.1更换阿里源
sh
# 下载阿里云的base源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
如果没有wget程序则使用curl下载
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
3.2更换163源码
sh
# 下载163的base源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
4.刷新源
sh
# 快速生成缓存
sudo yum makecache fast
5.查看是否添加成功
sh
# 查看yum源是否添加成功
sudo yum repolist