centos yum更换阿里镜像

#1.如果没有wget命令,则需要执行下面命令进行安装。为保险期间,先执行下面命令。
 yum install wget
 
#2.备份原镜像源,以免出错后可以恢复。
 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


#3.进入进入yum源配置文件夹,下载镜像
 cd /etc/yum.repos.d/

 #centos6
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
 #centos7
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

#4.生成缓存文件
   yum clean all
   yum makecache

posted @ 2021-09-16 14:37  至安  阅读(160)  评论(0编辑  收藏  举报