Centos更换可用YUM源
众所周知,CentOS7 已经EOL了,大多数的yum源都不可用了,所以在使用CentOS7的时候需要手动修改一下yum源的地址了。
下面我搜罗了一些当下可以正常使用的CentOS7 yum源。
备份原文件
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/
官方源
创建新的配置文件
直接复制下面的配置到/etc/yum.repos.d/CentOS-Base.repo文件中。
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=https://vault.centos.org/7.9.2009/?release=7.9.2009&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
清除YUM缓存
yum clean all
生成缓存并更新
yum makecache sudo yum update
其他源
阿里云
# CentOS6
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
# 或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
# CentOS7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# 或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
腾讯云
# CentOS6
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.cloud.tencent.com/repo/centos6_base.repo
# CentOS7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tencent.com/repo/centos7_base.repo
Mirrors
以下是支持centos vault的yum源(持续更新中)
| 序号 | 国家 | 厂家 | 地址 |
|---|---|---|---|
| 1 | 美国 | Centos官方 | https://vault.centos.org |
| 2 | 中国 | 腾讯云 | https://mirrors.cloud.tencent.com |
| 3 | 中国 | 阿里云 | https://developer.aliyun.com/mirror |
| 4 | 中国 | 网易 | https://mirrors.163.com |
| 5 | 中国 | 清华大学 | https://mirrors.tuna.tsinghua.edu.cn |
| 6 | 韩国 | moack | https://mirror.moack.co.kr |