YUM

安装管理工具:

  1. sudo yum clean all
  2. sudo yum makecache
  3. sudo yum install yum-utils

国内源

阿里云:

  1. # 备份原配置
  2. $ sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  3. # CentOS 7
  4. $ sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  5. # CentOS 8
  6. $ sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
  7. # 重新生成缓存
  8. $ sudo yum makecache

中科大:

  1. # CentOS 6/7
  2. $ sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
  3. -e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.ustc.edu.cn/centos|g' \
  4. -i.bak \
  5. /etc/yum.repos.d/CentOS-Base.repo
  6. # CentOS 8
  7. $ sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
  8. -e 's|^#baseurl=http://mirror.centos.org/$contentdir|baseurl=https://mirrors.ustc.edu.cn/centos|g' \
  9. -i.bak \
  10. /etc/yum.repos.d/CentOS-Base.repo \
  11. /etc/yum.repos.d/CentOS-Extras.repo \
  12. /etc/yum.repos.d/CentOS-AppStream.repo
  13. # 重新生成缓存
  14. $ sudo yum makecache

仓库管理

查看所有:

  1. $ sudo yum repolist all
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. repo id repo name status
  5. C7.0.1406-base/x86_64 CentOS-7.0.1406 - Base disabled
  6. 省略...
  7. base/7/x86_64 CentOS-7 - Base enabled: 10,070
  8. base-debuginfo/x86_64 CentOS-7 - Debuginfo disabled
  9. base-source/7 CentOS-7 - Base Sources disabled
  10. 省略...

启用/禁用:

  1. # 禁用
  2. sudo yum-config-manager --disable [仓库名]
  3. # 启用
  4. sudo yum-config-manager --enable [仓库名]

EPEL

安装

  1. sudo yum install epel-release
  2. sudo makecache

国内源

  1. # 中科大
  2. sudo sed -e 's|^metalink=|#metalink=|g' \
  3. -e 's|^#baseurl=https\?://download.fedoraproject.org/pub/epel/|baseurl=https://mirrors.ustc.edu.cn/epel/|g' \
  4. -i.bak \
  5. /etc/yum.repos.d/epel.repo