1、#查看已有源
$ ls -a /etc/yum.repos.d/
. .. CentOS-Base.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Vault.repo epel.repo yz.repo
2、#备份已有的源
$mv /etc/yum.repos.d /etc/yum.repos.d.backup
3、 #重建源目录
$mkdir /etc/yum.repos.d
4、
$wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
5、 #清理
$yum clean all
6、#重建本地缓存
$yum makecache
ps:看到下面的脚本忍不住要吐槽下,
modify_aliyun5_yum()
{
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
sed -i 's/\$releasever/5/' /etc/yum.repos.d/CentOS-Base.repo
wget -qO /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo
yum clean metadata
yum makecache
cd ~
}
modify_rhel5_yum()
{
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
wget -qO /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo
yum clean metadata
yum makecache
cd ~
}
modify_rhel6_yum()
{
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
wget -qO /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum clean metadata
yum makecache
cd ~
}
modify_rhel7_yum()
{
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -qO /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean metadata
yum makecache
cd ~
}