一、备份repo文件
代码语言:javascript
复制mkdir ~/yum.repos.bak
mv /etc/yum.repos.d/* ~/yum.repos.bak/
二、导入aliyun repo
代码语言:javascript
复制cd /etc/yum.repos.d
curl -o CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# CentOS 7
curl -o CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
# CentOS 8
三、安装ELRepo
代码语言:javascript
复制rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
yum install -y https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
# CentOS 7
yum install -y https://www.elrepo.org/elrepo-release-8.1-1.el8.elrepo.noarch.rpm
# CentOS 8
四、刷新yum缓存
代码语言:javascript
复制yum clean all && yum makecache