centos6 yum源失效的最新操作方式

1 备份

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
3 运行 yum makecache 生成缓存

[root@hadoop101 yum.repos.d]# yum makecache 
已加载插件:fastestmirror, refresh-packagekit, security
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
http://mirrors.aliyun.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
尝试其他镜像。
To address this issue please refer to the below knowledge base article 

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.

http://mirrors.aliyuncs.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/6/os/x86_64/repodata/repomd.xml: (28, 'connect() timed out!')
尝试其他镜像。
http://mirrors.cloud.aliyuncs.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.cloud.aliyuncs.com'"
尝试其他镜像。
错误:Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
[root@hadoop101 yum.repos.d]#   

4 替换源文件配置, 使用https://mirrors.aliyun.com/centos-vault

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
sed -i  's/http/https/g' /etc/yum.repos.d/CentOS-Base.repo
sed -i  's/$releasever/6.8/g' /etc/yum.repos.d/CentOS-Base.repo
sed -i  's/centos/centos-vault/g' /etc/yum.repos.d/CentOS-Base.repo
5 yum clean all && yum makecache

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
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` 文件中。 请注意,使用镜像可能会导致软件包的下载速度变慢,因此建议选择网络稳定且速度较快的镜像,以确保正常的软件更新和安装。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值