備份原來的yum源
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
設置aliyun的yum源
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
添加EPEL源
sudo wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo
清理緩存并生成新的緩存
sudo yum clean all
如果出現(xiàn)Another app is currently holding the yum lock; waiting for it to exit...錯誤提示,執(zhí)行下面
rm -f /var/run/yum.pid
重新生成緩存
sudo yum makecache