解决CentOS6停止更新支持后yum源失效的问题


这几天想在自己的虚拟机上安装nc,遇到了各种各样的问题,上度娘搜了好久,问题基本定位了是因为CentOS6停止更新、支持后yum源的问题,网上的解决办法有好多,基本上都是手动修改文件CentOS-Base.repo,试了网上很多的方法,还是有些问题

遇到的问题一

http://vault.centos.org/6.5/os/x86_64/repodata/repomd.xml: [Errno 14] Peer cert cannot be verified or peer cert invalid
Trying other mirror.
http://vault.centos.org/6.5/os/x86_64/Packages/nc-1.84-24.el6.x86_64.rpm: [Errno 14] Peer cert cannot be verified or peer cert invalid
Trying other mirror.

[root@hadoop01 yum.repos.d]# yum install nc
Loaded plugins: security
http://vault.centos.org/6.5/os/x86_64/repodata/repomd.xml: [Errno 14] Peer cert cannot be verified or peer cert invalid
Trying other mirror.
http://vault.centos.org/6.5/extras/x86_64/repodata/repomd.xml: [Errno 14] Peer cert cannot be verified or peer cert invalid
Trying other mirror.
http://vault.centos.org/6.5/updates/x86_64/repodata/repomd.xml: [Errno 14] Peer cert cannot be verified or peer cert invalid
Trying other mirror.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package nc.x86_64 0:1.84-24.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================
 Package                                   Arch                                          Version                                               Repository                                   Size
=================================================================================================================================================================================================
Installing:
 nc                                        x86_64                                        1.84-24.el6                                           base                                         57 k

Transaction Summary
=================================================================================================================================================================================================
Install       1 Package(s)

Total download size: 57 k
Installed size: 109 k
Is this ok [y/N]: y
Downloading Packages:
http://vault.centos.org/6.5/os/x86_64/Packages/nc-1.84-24.el6.x86_64.rpm: [Errno 14] Peer cert cannot be verified or peer cert invalid
Trying other mirror.


Error Downloading Packages:
  nc-1.84-24.el6.x86_64: failure: Packages/nc-1.84-24.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

遇到的问题二:

http://mirrors.aliyun.com/centos-vault/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - “The requested URL returned error: 404 Not Found”
http://mirrors.aliyun.com/centos-vault/6/os/x86_64/Packages/nc-1.84-24.el6.x86_64.rpm: [Errno 14] PYCURL ERROR 22 - “The requested URL returned error: 404 Not Found”
Trying other mirror.

[root@hadoop01 yum.repos.d]# yum install nc
Loaded plugins: security
http://mirrors.aliyun.com/centos-vault/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package nc.x86_64 0:1.84-24.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================
 Package                                   Arch                                          Version                                               Repository                                   Size
=================================================================================================================================================================================================
Installing:
 nc                                        x86_64                                        1.84-24.el6                                           base                                         57 k

Transaction Summary
=================================================================================================================================================================================================
Install       1 Package(s)

Total download size: 57 k
Installed size: 109 k
Is this ok [y/N]: y
Downloading Packages:
http://mirrors.aliyun.com/centos-vault/6/os/x86_64/Packages/nc-1.84-24.el6.x86_64.rpm: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.


Error Downloading Packages:
  nc-1.84-24.el6.x86_64: failure: Packages/nc-1.84-24.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

解决办法

最后终于在一个帖子中发现了简单得解决办法,依次执行以下命令,即可一键更换yum源为CentOS的Vault源

[root@hadoop01 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://file.kangle.odata.cc/repo/Centos-6.repo
[root@hadoop01 yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo http://file.kangle.odata.cc/repo/epel-6.repo
[root@hadoop01 yum.repos.d]# yum makecache

命令执行效果

[root@hadoop01 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://file.kangle.odata.cc/repo/Centos-6.repo
--2021-01-03 22:16:47--  http://file.kangle.odata.cc/repo/Centos-6.repo
正在解析主机 file.kangle.odata.cc... 150.242.98.89
正在连接 file.kangle.odata.cc|150.242.98.89|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:3331 (3.3K) [text/plain]
正在保存至:/etc/yum.repos.d/CentOS-Base.repo”

100%[=======================================================================================================================================================>] 3,331       --.-K/s   in 0s      

2021-01-03 22:16:49 (385 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [3331/3331])

[root@hadoop01 yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo http://file.kangle.odata.cc/repo/epel-6.repo
--2021-01-03 22:17:02--  http://file.kangle.odata.cc/repo/epel-6.repo
正在解析主机 file.kangle.odata.cc... 150.242.98.89
正在连接 file.kangle.odata.cc|150.242.98.89|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1474 (1.4K) [text/plain]
正在保存至:/etc/yum.repos.d/epel.repo”

100%[=======================================================================================================================================================>] 1,474       --.-K/s   in 0s      

2021-01-03 22:17:02 (399 MB/s) - 已保存 “/etc/yum.repos.d/epel.repo” [1474/1474])

[root@hadoop01 yum.repos.d]# yum makecache
Loaded plugins: security
base                                                                                                                                                                      | 3.7 kB     00:00     
base/group_gz                                                                                                                                                             | 242 kB     00:00     
base/filelists_db                                                                                                                                                         | 6.4 MB     00:05     
base/other_db                                                                                                                                                             | 2.8 MB     00:02     
epel                                                                                                                                                                      | 4.7 kB     00:00     
epel/group_gz                                                                                                                                                             |  74 kB     00:00     
epel/filelists_db                                                                                                                                                         | 7.9 MB     00:06     
epel/updateinfo                                                                                                                                                           | 788 kB     00:00     
epel/prestodelta                                                                                                                                                          |  574 B     00:00     
epel/primary_db                                                                                                                                                           | 6.1 MB     00:05     
epel/other_db                                                                                                                                                             | 3.0 MB     00:02     
extras                                                                                                                                                                    | 3.4 kB     00:00     
extras/filelists_db                                                                                                                                                       |  24 kB     00:00     
extras/prestodelta                                                                                                                                                        | 2.2 kB     00:00     
extras/other_db                                                                                                                                                           |  14 kB     00:00     
updates                                                                                                                                                                   | 3.4 kB     00:00     
updates/filelists_db                                                                                                                                                      | 8.4 MB     00:07     
updates/prestodelta                                                                                                                                                       | 357 kB     00:00     
updates/primary_db                                                                                                                                                        |  12 MB     00:10     
updates/other_db                                                                                                                                                          | 479 kB     00:00     
Metadata Cache Created

安装测试

再次进行安装测试后,安装成功

[root@hadoop01 yum.repos.d]# yum install nc
Loaded plugins: security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package nc.x86_64 0:1.84-24.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================
 Package                                   Arch                                          Version                                               Repository                                   Size
=================================================================================================================================================================================================
Installing:
 nc                                        x86_64                                        1.84-24.el6                                           base                                         57 k

Transaction Summary
=================================================================================================================================================================================================
Install       1 Package(s)

Total download size: 57 k
Installed size: 109 k
Is this ok [y/N]: y
Downloading Packages:
nc-1.84-24.el6.x86_64.rpm                                                                                                                                                 |  57 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : nc-1.84-24.el6.x86_64                                                                                                                                                         1/1 
  Verifying  : nc-1.84-24.el6.x86_64                                                                                                                                                         1/1 

Installed:
  nc.x86_64 0:1.84-24.el6                                                                                                                                                                        

Complete!
[root@hadoop01 yum.repos.d]# nc -help
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port]
          [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version]
          [-x proxy_address[:port]] [hostname] [port[s]]
        Command Summary:
                -4              Use IPv4
                -6              Use IPv6

文章转载自:
http://f.sendong.com/index.php/knowledgebase/86/解决CentOS6停止更新支持后yum源失效.html
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
CentOS 6 是一种自由开放源代码的企业级Linux发行版。然而,官方源失效可能是由于多种原因引起的,如源服务器维护、网络故障、软件更新等。 一种解决办法是更换官方源为镜像源。镜像源是由社区提供的与官方源一样的软件包仓库,可以替代官方源使用。通过更换官方源为镜像源,我们可以继续获取软件包的更新和安装。 步骤如下: 1. 打开CentOS 6系统的终端或命令行界面。 2. 编辑 `/etc/yum.repos.d/CentOS-Base.repo` 文件,可以使用 `vi` 或 `nano` 文本编辑器打开该文件。 3. 在文件中找到 `[base]` 和 `[updates]` 部分,并注释掉原有的 `baseurl` 行,用新的镜像源地址替代。 例如: - 将 `baseurl=http://xxx.xxx.xxx.xxx/CentOS/6/os/$basearch/` 替换为 `baseurl=http://mirror.centos.org/centos/6/os/$basearch/` - 将 `baseurl=http://xxx.xxx.xxx.xxx/CentOS/6/updates/$basearch/` 替换为 `baseurl=http://mirror.centos.org/centos/6/updates/$basearch/` 4. 保存修改后的文件。 5. 清除系统的 Yum 缓存:在终端中输入 `yum clean all` 命令。 6. 更新yum缓存:在终端中输入 `yum makecache` 命令。 7. 现在,您应该能够使用新的镜像源进行软件包的更新和安装了。 如果以上方法无效,您还可以尝试使用其他第三方的镜像源,如阿里云、清华大学等提供的源。请在互联网上搜索相关的镜像源地址,并按照上述步骤将它们替换到 `/etc/yum.repos.d/CentOS-Base.repo` 文件中。 请注意,使用镜像源可能会导致软件包的下载速度变慢,因此建议选择网络稳定且速度较快的镜像源,以确保正常的软件更新和安装。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值