centos替换源的时候,今天才知道,老版本的源华为和阿里云,已经不做维护了,需要把源修改为http://vault.centos.org 的,才可以正常的访问。
下图可以看到centos的各个版本源信息。
查看系统信息
#查看版本信息
rpm -qi centos-release
#查看系统信息
uname -a
#查看redhat版本
cat /etc/redhat-release
#查看linux版本信息
cat /proc/version
查看版本信息
替换源
#这个是阿里云的源
#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
#目测现在6版本已经不维护了
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-6-anon.repo
#需要替换为 http://vault.centos.org
sed -i "s#https://mirrors.huaweicloud.com#http://vault.centos.org#g" CentOS-Base.repo
#清空缓存
yum clean all
#生成缓存信息
yum makecache
下图可以看到,华为云,已经不维护老版本的centos了
配置信息
$releasever 这个变量,就是命令rpm -qi centos-release
的变量信息。 我们使用下面的配置就可以正确的更新源了。
# 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 - mirrors.huaweicloud.com
baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/
#mirrorlist=https://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://vault.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.huaweicloud.com
baseurl=http://vault.centos.org/centos/$releasever/updates/$basearch/
#mirrorlist=https://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://vault.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.huaweicloud.com
baseurl=http://vault.centos.org/centos/$releasever/extras/$basearch/
#mirrorlist=https://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://vault.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.huaweicloud.com
baseurl=http://vault.centos.org/centos/$releasever/centosplus/$basearch/
#mirrorlist=https://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.huaweicloud.com
baseurl=http://vault.centos.org/centos/$releasever/contrib/$basearch/
#mirrorlist=https://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/centos/RPM-GPG-KEY-CentOS-6
可以看到缓存建立成功嘎嘎棒
常见问题
https://mirrors.huaweicloud.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - “The requested URL returned error: 404 Not Found”
出现这个问题,是由于华为已经不维护centos6版本的源了。