CentOS 6.5上yum源用不了如何更换

时间:2023年05月06日

/

来源:网络

/

编辑:佚名

最近在CentOS 6上搭建DNS服务器,使用yum下载安装软件报错,YumRepo Error: All mirror URLs are not using ftp, http[s] or file,如下图:

解决方法:
1、先备份CentOS的repo源文件
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/repo.bak
2、去阿里云下载repo源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
$releasever 是获取你centos的版本号的,例如我的centos的版本号为6.5,获取到的为6,但是已经找不到了,所以直接全局改成7即可
原因
原centos/6/ 下已经没有相关的文件,自然找不到报404
阿里的Centos-6.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.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

3、编辑CentOS-Base.repo文件,vim /etc/yum.repos.d/CentOS-Base.repo
  输入 ggdG 回车将所有内容删除,然后粘贴以下内容至文件中,保存退出
复制代码
# 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.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/os/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/os/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/updates/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/updates/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/extras/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/extras/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6
复制代码
出现问题参考的文章
将下面的配置信息复制替换掉CentOS-Base.repo文件里的内容,亲测有效~~~但是一定要注意,里面的信息要根据自己的centos版本做相应的调整,我的是6.5版本的就修改6.5,如果你的是6.6就修改为6.6!!!

文章地址:https://blog.csdn.net/qq_27052367/article/details/127348658
# 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.5 - Base
baseurl=http://mirrors.aliyun.com/centos-vault/6.6/os/x86_64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
[updates]
name=CentOS-6.5 - Updates
baseurl=http://mirrors.aliyun.com/centos-vault/6.6/updates/x86_64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
[extras]
name=CentOS-6.5 - Extras
baseurl=http://mirrors.aliyun.com/centos-vault/6.6/extras/x86_64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
[centosplus]
name=CentOS-6.5 - Plus
baseurl=http://mirrors.aliyun.com/centos-vault/6.6/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
[contrib]
name=CentOS-6.5 - Contrib
baseurl=http://mirrors.aliyun.com/centos-vault/6.6/contrib/x86_64/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
但是这个CentOS-Base.repo有点小问题,其中gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6没有了,出现404
gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6
修改后的
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6 
修改后的CentOS-Base.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.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/os/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/os/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/os/$basearch/
gpgcheck=1
#gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/updates/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/updates/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/updates/$basearch/
gpgcheck=1
#gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-Official
#gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 
#gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
#gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/extras/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/extras/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/extras/$basearch/
gpgcheck=1
#gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6 
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
#gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6 
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyun.com/centos-vault/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
#gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6 
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
4、更新repo源
yum clean all
yum update
5、安装bind程序
其中如果按照修改前的执行yum安装命令需要加上--nogpgcheck即yum install xx --nogpgcheck
yum install bind-chroot -y --nogpgcheck
修改后的不需要这一步。
GPG key retrieval failed: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
方法1. 每次执行yum的时候都添加--nogpgcheck,例如:yum install XXX --nogpgcheck
方法2  1.导入repo:gpg --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
        这样并没有实际修改repo 文件!!!还是修改文件吧(不推荐)
      2.修改repo文件 把gpgkey后面的6改成7
这个问题简单总结了一下!
GPG key retrieval failed: [Errno 14] PYCURL ERROR 7 - "couldn't connect to host"
简单的翻译:GPG密钥检索失败:[14] PYCURL errno的错误 - “无法连接到主机”
解决办法:
1、检查自己的DNS是不是正常,ping centos.org 和ping www.baidu.com
  如果都是正常,那DNS配置就不存在问题了。如果感觉DNS还是有问题就换个
vi /etc/resolv.conf
nameserver 8.8.8.8
2、实质性问题就是自己系统没有yum的GPG密钥
   查看自己系统版本
   cat /etc/issue
   登陆mirrors.163.com 找到自己系统对应的密钥
   RPM-GPG-KEY-CentOS-3
  RPM-GPG-KEY-CentOS-4
  RPM-GPG-KEY-CentOS-5
  RPM-GPG-KEY-CentOS-6
   使用命令rpm --import进行导入
  rpm --import http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
  rpm --import http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
然后你再试一下yum -y update 你就会发现一切正常了!
猜你需要

豫ICP备2021026617号-1  豫公网安备:41172602000185   Copyright © 2021-2028 www.78moban.com/ All Rights Reserved

本站作品均来自互联网,转载目的在于传递更多信息,并不代表本站赞同其观点和对其真实性负责。如有侵犯您的版权,请联系 1565229909#qq.com(把#改成@),我们将立即处理。