centos7下面yum安装软件报错,显示找不到镜像地址。

【问题原因和解决办法】

dns解析的问题,处理办法:
vim /etc/resolv.conf  加入:


nameserver 8.8.8.8
nameserver 8.8.4.4
search localdomain

----------------------------------------------------------------------------

【原帖地址】http://blog.youkuaiyun.com/reblue520/article/details/52541138


# yum install -y epel-release
Loaded plugins: fastestmirror
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
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Temporary failure in name resolution"




 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:


     1. Contact the upstream for the repository and get them to fix the problem.


     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).


     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:


            yum-config-manager --disable <repoid>


     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:


            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true


Cannot find a valid baseurl for repo: base/7/x86_64




dns解析的问题,处理办法:
vim /etc/resolv.conf  加入:


nameserver 8.8.8.8
nameserver 8.8.4.4
search localdomain

CentOS 7 系统中使用 `yum` 镜像源时,可能会遇到各种错误。这些错误通常与网络连接、镜像源配置、GPG 密钥验证或软件包依赖性相关。以下是常见的错误及其解决方案: ### 1. **Yum 源无法访问或超时** - **现象**:执行 `yum makecache` 或 `yum install` 时提示 "Could not retrieve mirrorlist" 或 "Connection timed out"。 - **原因**:DNS 解析问题、网络不通、镜像地址失效等。 - **解决方法**: - 更换默认的镜像源为国内镜像(如阿里云、清华源): ```bash 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 ``` - 检查 `/etc/resolv.conf` 文件中的 DNS 设置是否正常。 - 修改 `/etc/yum.conf` 中的 `timeout` 和 `retries` 参数以增加等待时间。 ### 2. **GPG 验证失败** - **现象**:提示 `Public key for *.rpm is not installed` 或 `NOKEY` 错误。 - **原因**:缺少 GPG 公钥或签名不匹配。 - **解决方法**: - 安装缺失的 GPG 密钥: ```bash rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 ``` - 若确认安全性无问题,可临时禁用 GPG 检查: ```bash yum install <package> --nogpgcheck ``` ### 3. **EPEL 源安装后无法使用** - **现象**:添加 EPEL 源后,`yum` 报错不到 `epel` 仓库。 - **原因**:EPEL 源配置文件未正确设置或 URL 失效。 - **解决方法**: - 安装官方 EPEL 发行包: ```bash yum install epel-release ``` - 手动编辑 `/etc/yum.repos.d/epel.repo`,确保 `baseurl` 或 `mirrorlist` 正确可用,例如: ``` [epel] name=Extra Packages for Enterprise Linux 7 - $basearch baseurl=https://download.fedoraproject.org/pub/epel/7/$basearch enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 ``` ### 4. **缓存损坏导致的元数据错误** - **现象**:提示 `Metadata file does not match checksum` 或 `Cannot retrieve repository metadata (repomd.xml)`。 - **原因**:本地缓存文件损坏或镜像源同步异常。 - **解决方法**: - 清除缓存并重新生成: ```bash yum clean all rm -rf /var/cache/yum/* yum makecache ``` ### 5. **依赖关系解析失败** - **现象**:提示 `Error: Package: ... Requires: ...`。 - **原因**:软件仓库中缺少所需依赖包或版本冲突。 - **解决方法**: - 使用 `yum deplist <package>` 查看具体依赖关系。 - 尝试更换更稳定的镜像源。 - 使用 `yum install <package> --skip-broken` 跳过有问题的依赖项。 ---
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值