CentOS7配置阿里云yum源

[TOC]

备份

  1. [root@bogon ~]# cd /etc/yum.repos.d/
  2. [root@bogon yum.repos.d]# mkdir repo_bak
  3. [root@bogon yum.repos.d]# mv *.repo repo_bak/
  4. [root@bogon yum.repos.d]# ls
  5. repo_bak

下载新的CentOS-Base.repo 到/etc/yum.repos.d/

wget -O /etc/yum.repos.d/CentOS-Base.repo

  1. [root@bogon yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  2. --2018-02-09 16:33:46-- http://mirrors.aliyun.com/repo/Centos-7.repo
  3. Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 124.14.2.234, 124.14.2.235, 124.14.2.217, ...
  4. Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|124.14.2.234|:80... connected.
  5. HTTP request sent, awaiting response... 200 OK
  6. Length: 2573 (2.5K) [application/octet-stream]
  7. Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo
  8. 100%[========================================================================================>] 2,573 --.-K/s in 0s
  9. 2018-02-09 16:33:47 (182 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo saved [2573/2573]
  10. [root@bogon yum.repos.d]# ls
  11. CentOS-Base.repo repo_bak

之后运行yum clean all 清除缓存,运行 yum makecache 生成新的缓存

  1. [root@bogon yum.repos.d]# yum clean all
  2. Loaded plugins: fastestmirror
  3. Cleaning repos: base extras updates
  4. Cleaning up everything
  5. Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
  6. Cleaning up list of fastest mirrors
  7. [root@bogon yum.repos.d]# yum makecache
  8. Loaded plugins: fastestmirror
  9. base | 3.6 kB 00:00:00
  10. extras | 3.4 kB 00:00:00
  11. updates | 3.4 kB 00:00:00
  12. (1/12): base/7/x86_64/group_gz | 156 kB 00:00:00
  13. (2/12): extras/7/x86_64/filelists_db | 636 kB 00:00:07
  14. (3/12): extras/7/x86_64/primary_db