阿里云yum源
#备份
[root@qls ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
#下载新的CentOS-Base.repo 到/etc/yum.repos.d/
[root@qls ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#添加epel源
[root@qls ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
华为yum源
#清理已经存在的yum源
cd /etc/yum.repos.d && rm -rf *
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
#新增epel源
yum remove -y epel-release
yum install -y https://repo.huaweicloud.com/epel/epel-release-latest-7.noarch.rpm
sed -i "s/#baseurl/baseurl/g" /etc/yum.repos.d/epel.repo
sed -i "s/mirrorlist/#mirrorlist/g" /etc/yum.repos.d/epel.repo
sed -i "s@http://download.fedoraproject.org/pub@https://repo.huaweicloud.com@g" /etc/yum.repos.d/epel.repo
yum clean all //清除原有yum缓存
yum makecache //刷新缓存
yum repolist all //查看所有配置可以使用的文件,会自动刷新缓存