CentOS7更换国内yum源

1.备份原Base源

cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
# ====== 更换清华源请使用 ======
cp CentOS-Base.repo CentOS-Base.repo.bak

2.更换国内源

下面的操作任选一个即可

阿里镜像源

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

清华镜像源

sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
         -e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' \
         -i.bak \
         /etc/yum.repos.d/CentOS-*.repo

3.更新软件包缓存

yum makecache

参考:
阿里源CentOS 镜像:https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b113id1k6
清华源CentOS 镜像使用帮助:https://mirrors.tuna.tsinghua.edu.cn/help/centos/

上一篇:【21】牛客网BC23 时间转换


下一篇:day23 rpm与yum安装nginx