CentOS6 yum源失效及重新制作方法
由于CentOS6原仓库于2020.11.30停止维护更新且被移除了,国内各大镜像源是同步的,所以也都失效了。如果想要继续使用yum仓库的话需要进行配置文件的修改,使用官网的旧版存档 https://vault.centos.org/ ,该旧版存档源由开发者维护,所以一些安全更新等可能会不是很及时,且在国外下载获取速度相对慢些。因此我们可以选用阿里云的镜像,具体的修改方法如下:
1.查看当前系统版本
命令:
cat /etc/issue
[root@LS ~]# cat /etc/issue
CentOS release 6.9 (Final)
Kernel \r on an \m
2.备份并修改 /etc/yum.repos.d/CentOS-Base.repo文件
命令:
备份
[root@LS ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
修改
[root@LS ~]# vim /etc/yum.repos.d/CentOS-Base.repo
修改相应的URL链接,之前查询到该系统的版本为6.9,不同版本的仓库须上其站点查看相应的路径
#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.9 - Base - mirrors.aliyun.com
lovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.9/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-6.9 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.9/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-6.9 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.9/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.9 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.9/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
[contrib]
name=CentOS-6.9 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.9/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
~
"/etc/yum.repos.d/CentOS-Base.repo" 52L, 1780C
3.执行
命令:
清理并重新制作缓存
yum clean all && yum makecache
升级内核和软件
yum -y update
执行完成后即可使用yum下载所需的软件和命令了
#最后需要注意的是确保系统的网络配置已经设置好,能够ping通外网,否则会提示无法连接至URL指定链接