centos6更换yum源报错的解决方案

一、背景

  最近在安装centos6上通过yum下载vsftpd时,无法下载成功,查了很多资料说需要更好yum源,查了一些资料,很多yum源都过期了,无法解决问题,经常报下面错误。是执行下面yum命令报错的。

sudo yum makecache
sudo yum -y install vsftpd

http://mirrors.cloud.aliyuncs.com/epel/6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"


Trying other mirror.


To address this issue please refer to the below wiki article


https://wiki.centos.org/yum-errors


If above article doesn't help to resolve this issue please use https://bugs.centos.org/.


Error: Cannot retrieve repository metadata (repomd.xml) for repository: epel. Please verify its path and try again


二、解决方案

根据报错信息,说是目前的yum源找不到内容,让修改yum源,具体步骤如下。

1、 到达yum文件所在位置,centos6执行下面命令。

cd /etc/yum.repos.d/

2、备份原来的yum源文件,方便后面报错可以还原回来

sudo mv epel.repo  epel.repo.bak
sudo mv CentOS-Base.repo  CentOS-Base.repo.bak

3、下载新的yum源

(1)这个找了好久才找到,操作时间在2021年10月3日,至少这个时间前后改源可以用的,可以试试。

(2)依次执行这两个命令更换yum源。

sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
sudo wget -O /etc/yum.repos.d/epel.repo http://file.kangle.odata.cc/repo/epel-6.repo 

4、安装好后执行下面命令

(1)作用是把服务器的包信息下载到本地电脑缓存起来,makecache建立一个缓存 ,以后用install时就在缓存中搜索,提高了速度。

sudo yum makecache

三、总结

    以上就是centos6更换yum源报错的解决方案所有内容,在这里记录一下,假如用的是centos6而且yum install的时候报错了可以参考一下,希望能够帮到大家,觉得不错的话,欢迎微信搜索关注java基础笔记,后面会不断更新相关知识,大家一起进步。   

上一篇:【nodejs】让nodejs像后端mvc框架(asp.net mvc)一样处理请求--请求处理函数装饰器注册篇(5/8)【controller+action】


下一篇:shel脚本基础系列(二)语法+运算+判断(上)