Centos6更换Yum的repo软件源

Centos6于2021年结束了生命周期,随之而来的是repo源配置文件失效.
这里我们需要手动更新一下CentOS-Base.repo文件,替换旧的repo软件源

Centos6备份旧的CentOS-Base.repo

CentOS-Base.repo已经失效其实可以不用备份
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

一键替换Yum的repo软件源

官方repo源

echo -ne '
[base]
name=CentOS-6.10 -Base -vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6.10 -Updates -vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful

[extras]
name=CentOS-6.10 -Extras -vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages

[centosplus]
name=CentOS-6.10 -Plus -vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6
#contrib -packages by Centos Users

[contrib]
name=CentOS-6.10 -Contrib -vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6
' > /etc/yum.repos.d/CentOS-Base.repo

清华repo源

echo -ne '
[base]
name=CentOS-6.10 -Base -mirrors.tuna.tsinghua.edu.cn/centos-vault
failovermethod=priority
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6.10 -Updates -mirrors.tuna.tsinghua.edu.cn/centos-vault
failovermethod=priority
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful

[extras]
name=CentOS-6.10 -Extras -mirrors.tuna.tsinghua.edu.cn/centos-vault
failovermethod=priority
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages

[centosplus]
name=CentOS-6.10 -Plus -mirrors.tuna.tsinghua.edu.cn/centos-vault
failovermethod=priority
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-6
#contrib -packages by Centos Users

[contrib]
name=CentOS-6.10 -Contrib -mirrors.tuna.tsinghua.edu.cn/centos-vault
failovermethod=priority
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-6
' > /etc/yum.repos.d/CentOS-Base.repo

清除yum缓存,更新软件包缓存


yum makecache
参考文章
https://mirrors.tuna.tsinghua.edu.cn/help/centos/

此处评论已关闭