CentOS 6 Yum 源无效 停止维护解决办法

最近给 CentOS 6 服务器安装软件时出现了错误:文章源自靠谱运维-https://www.ixdba.net/archives/1600

[root@localhost ~]# yum install tree
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
http://mirrors.163.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - “The requested URL returned error: 404”
Trying other mirror.

更换基础源

使用 vi /etc/yum.repos.d/CentOS-Base.repo 命令编辑yum 配置文件。
然后将里面的默认内容全部删除,再替换成以下内容:文章源自靠谱运维-https://www.ixdba.net/archives/1600

[base]
name=CentOS-$releasever - Base
failovermethod=priority
baseurl=https://vault.centos.org/centos/$releasever/os/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
# released updates
[updates]
name=CentOS-$releasever - Updates
failovermethod=priority
baseurl=https://vault.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
# additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://vault.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

然后保存退出,应该就可以正常安装软件了,不行就重启服务器再试试看。文章源自靠谱运维-https://www.ixdba.net/archives/1600

这里使用的是Centos的官方源,这个源除了速度有点慢,一直都是可以用的。适用于CentOS 6 的所有版本。文章源自靠谱运维-https://www.ixdba.net/archives/1600

如果觉得慢,可以使用阿里云的源,CentOS-Base.repo内容如下:文章源自靠谱运维-https://www.ixdba.net/archives/1600

# 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.10 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6.10 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/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.10 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/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.10 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

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

更换epel源

如果使用的是 epel源,
就用命令 vi /etc/yum.repos.d/epel.repo ,编辑epel源文件,删除全部默认内容,再替换为以下内容:文章源自靠谱运维-https://www.ixdba.net/archives/1600

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://archives.fedoraproject.org/pub/archive/epel/6/$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

然后保存退出,应该就可以正常安装软件了。文章源自靠谱运维-https://www.ixdba.net/archives/1600

如果还不行就执行下面这三条命令,重启服务器再试试。文章源自靠谱运维-https://www.ixdba.net/archives/1600

yum clean all
yum makecache
yum update
文章源自靠谱运维-https://www.ixdba.net/archives/1600
  • 本文由 发表于 2021年4月26日09:45:41
  • 转载请务必保留本文链接:https://www.ixdba.net/archives/1600
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: