CentOS配置:将默认yum源更改为163源或阿里云源

原因

CentOS默认的yum源可能不是国内镜像源,导致使用yum进行在线安装及更新时,速度不是很理想。此时需要将yum源设置为国内镜像源。国内的开源镜像站点主要有网易和阿里云。

配置过程

  • 首先备份系统自带的yum源配置文件/etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  • 下载163或阿里云的yum源配置文件到/etc/yum.repos.d/,并命名为CentOS-Base.repo

    • CentOS7

      // 163源
      wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
      // 阿里云源
      wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    • CentOS6

      // 163源
      wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
      // 阿里云源
      wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
  • 运行以下命令生成缓存

yum clean all
yum makecache
  • 运行命令yum repolist,查看当前yum源的地址,确认是否更改成功

猜你喜欢

转载自blog.csdn.net/For_course/article/details/82688203
今日推荐