YUM
安装管理工具:
sudo yum clean all
sudo yum makecache
sudo yum install yum-utils
国内源
阿里云:
# 备份原配置
$ sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# CentOS 7
$ sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# CentOS 8
$ sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
# 重新生成缓存
$ sudo yum makecache
中科大:
# CentOS 6/7
$ sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.ustc.edu.cn/centos|g' \
-i.bak \
/etc/yum.repos.d/CentOS-Base.repo
# CentOS 8
$ sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://mirror.centos.org/$contentdir|baseurl=https://mirrors.ustc.edu.cn/centos|g' \
-i.bak \
/etc/yum.repos.d/CentOS-Base.repo \
/etc/yum.repos.d/CentOS-Extras.repo \
/etc/yum.repos.d/CentOS-AppStream.repo
# 重新生成缓存
$ sudo yum makecache
仓库管理
查看所有:
$ sudo yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id repo name status
C7.0.1406-base/x86_64 CentOS-7.0.1406 - Base disabled
省略...
base/7/x86_64 CentOS-7 - Base enabled: 10,070
base-debuginfo/x86_64 CentOS-7 - Debuginfo disabled
base-source/7 CentOS-7 - Base Sources disabled
省略...
启用/禁用:
# 禁用
sudo yum-config-manager --disable [仓库名]
# 启用
sudo yum-config-manager --enable [仓库名]
EPEL
安装
sudo yum install epel-release
sudo makecache
国内源
# 中科大
sudo sed -e 's|^metalink=|#metalink=|g' \
-e 's|^#baseurl=https\?://download.fedoraproject.org/pub/epel/|baseurl=https://mirrors.ustc.edu.cn/epel/|g' \
-i.bak \
/etc/yum.repos.d/epel.repo