配置yum源
- 網(wǎng)易源:http://mirrors.163.com/
- 阿里源:https://developer.aliyun.com/mirror/
確保有wget命令 yum install wget -y
安裝阿里云和epel鏡像
epel.repo centos-base.repo 指定了yum倉(cāng)庫(kù)的網(wǎng)站地址
1.備份現(xiàn)有repo倉(cāng)庫(kù)
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2.下載新的repo文件
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3.清空舊yum緩存移斩,生成新的緩存
yum clean all
yum makecache
4.針對(duì)阿里云鏡像够挂,可能出現(xiàn)無(wú)法解析地址的異常
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
5.配置epel源
epel(RHEL 7)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
epel(RHEL 6)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
epel(RHEL 5)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo
再使用 yum clean all 和 yum makecache 來(lái)清除緩存和新建緩存