这两天针对部分CentOS6系列进行更新维护时发现无法连接更新源,发生报错,不管是连接官方的还是阿里或清华等都报错。
根据查询CentOS6的生命周期到了,官方的源失效了,国内的镜像源都是同步官方的,所以也大部分失效了,这个时候需要使用到Vault-repo,
1、查询本地已有Vault.repo文件
2、复制该文件最后面CentOS6的相关镜像源信息;这儿的CentOS版本根据你当时该系统安装时啥版本这儿就显示啥版本,例如当时安装的是CentOS6.6这儿最后显示的就是6.6;
[C6.6-base] name=CentOS-6.6 - Base baseurl=http://vault.centos.org/6.6/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=0 [C6.6-updates] name=CentOS-6.6 - Updates baseurl=http://vault.centos.org/6.6/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=0 [C6.6-extras] name=CentOS-6.6 - Extras baseurl=http://vault.centos.org/6.6/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=0 [C6.6-contrib] name=CentOS-6.6 - Contrib baseurl=http://vault.centos.org/6.6/contrib/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=0 [C6.6-centosplus] name=CentOS-6.6 - CentOSPlus baseurl=http://vault.centos.org/6.6/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=0
3、以防出错先备份CentOS-Base.repo源文件,然后把该文件内的源信息删除掉并粘贴刚刚复制Vault.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. # # [C6.6-base] name=CentOS-6.6 - Base baseurl=http://vault.centos.org/6.6/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=0 [C6.6-updates] name=CentOS-6.6 - Updates baseurl=http://vault.centos.org/6.6/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=0 [C6.6-extras] name=CentOS-6.6 - Extras baseurl=http://vault.centos.org/6.6/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=0 [C6.6-contrib] name=CentOS-6.6 - Contrib baseurl=http://vault.centos.org/6.6/contrib/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=0 [C6.6-centosplus] name=CentOS-6.6 - CentOSPlus baseurl=http://vault.centos.org/6.6/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=0
4、根据YUM规范修改仓库命名、根据当前系统版本相应的修改系统版本号及标示名称、并且启用仓库。
# 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-6.8 - Base baseurl=http://vault.centos.org/6.8/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=1 [updates] name=CentOS-6.8 - Updates baseurl=http://vault.centos.org/6.8/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=1 [extras] name=CentOS-6.8 - Extras baseurl=http://vault.centos.org/6.8/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=1 [contrib] name=CentOS-6.8 - Contrib baseurl=http://vault.centos.org/6.8/contrib/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=1 [centosplus] name=CentOS-6.8 - CentOSPlus baseurl=http://vault.centos.org/6.8/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=1
5、清除旧缓存创建新缓存: yum clean all && yum makecache