关于CentOs7 yum 安装依赖retrieve mirrorlist报错的问题

问题描述:使用CentOs7安装依赖yum install gcc glibc-devel make ncurses-devel openssl-devel xmlto -y 时报错,链接不上centOs7镜像。

问题排查:

这个错误表明 yum 无法从 CentOS 的镜像源获取更新的信息或软件包列表,导致无法继续安装过程。这通常是因为网络连接问题或者镜像源配置有误引起的。

可以尝试以下几种解决方法来修复这个问题:

  1. 检查网络连接:首先确保你的服务器能够访问互联网,尝试用浏览器或者 curl 命令访问 http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock 确认是否可以正常访问。

  2. 检查镜像源配置:检查 /etc/yum.repos.d/CentOS-Base.repo 文件中的 CentOS 镜像源配置。确保配置文件中的 baseurl 或者 mirrorlist 参数指向正确的镜像源地址。可以尝试使用官方的镜像源地址或者其他可靠的镜像源地址。

  3. 使用备用镜像源:如果当前镜像源无法正常工作,可以暂时禁用它,并尝试使用其他镜像源。例如,可以使用 yum --disablerepo=base ... 来临时禁用基础镜像源。

  4. 重建缓存:如果配置文件更改后仍然遇到问题,可以尝试清理 yum 的缓存并重新生成它们:

    yum clean all                    yum makecache

解决方法:

1)关闭防火墙,检查服务器是否正确配置了DNS解析。

vi /etc/resolv.conf 

        在文件中添加 :

nameserver 8.8.8.8
nameserver 8.8.4.4

(按 i 就可以切换编辑模式,编辑之后,需要保存退出,先按esc,然后输入“:wq”保存退出。)

2)尝试 ping 其他已知的域名,检查是否存在网络问题。

3) yum clean all  (因为我的Linux在Ping百度是正常的,所以3、4我尝试了好几次)

4)yum repolist

5)yum install gcc glibc-devel make ncurses-devel openssl-devel xmlto -y (就正常了)

另:

centos7更换国内源


在CentOS 7上更换为国内源可以通过替换/etc/yum.repos.d/CentOS-Base.repo文件来实现。以下是一些常用的国内源以及如何更换的示例:

阿里云源:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache


清华大学源:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tuna.tsinghua.edu.cn/git/repo/CentOS-7.repo
yum clean all
yum makecache

中国科技大学源:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.ustc.edu.cn/help/centos.7.repo
yum clean all
yum makecache

更换源后,使用yum update命令进行更新。

注意:在更换源之前,请确保备份当前的源配置文件,以防更换后源无法使用时可以恢复。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值