Linux 安装yum报错Could not resolve host

Linux 安装yum报错Could not resolve host


已加载插件:langpacks
http://update.cs2c.com.cn:8080/NS/V7/V7Update4/os/adv/lic/base/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: update.cs2c.com.cn; 未知的错误"
正在尝试其它镜像。


 One of the configured repositories failed (NeoKylin Linux Advanced Server 7 - Os),
 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. Run the command with the repository temporarily disabled
            yum --disablerepo=ns7-adv-os ...

     4. Disable the repository permanently, 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 ns7-adv-os
        or
            subscription-manager repos --disable=ns7-adv-os

     5. 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=ns7-adv-os.skip_if_unavailable=true

failure: repodata/repomd.xml from ns7-adv-os: [Errno 256] No more mirrors to try.
http://update.cs2c.com.cn:8080/NS/V7/V7Update4/os/adv/lic/base/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: update.cs2c.com.cn; 未知的错误"


解决办法:在/etc/resolv.conf文件中添加 :nameserver 8.8.8.8

### CentOS 7 中 `yum` 命令遇到 “Could not resolve host: mirrorlist.centos.org” 错误的解决方案 当执行 `yum` 更新或其他操作时,如果收到错误提示:“Could not resolve host: mirrorlist.centos.org”,这通常意味着系统无法解析该主机名。此问题可能由多种因素引起,包括 DNS 配置不当、网络连接不稳定或是特定于地理位置的访问限制。 #### 修改 YUM 源配置文件 一种常见的解决办法是更换默认的镜像源为更稳定可靠的国内镜像站点。具体做法如下: 编辑 `/etc/yum.repos.d/CentOS-Base.repo` 文件,在其中找到所有指向 `mirrorlist.centos.org` 的 URL 并将其替换为中国科学技术大学 (USTC) 或其他可信的中国境内镜像站地址[^3]。 对于 USTC 镜像来说,应将原来的 baseurl 设置改为类似于下面的形式: ```bash baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/ ``` 完成修改之后保存更改并退出编辑器。接着运行命令刷新缓存以使新的设置生效: ```bash sudo yum clean all && sudo yum makecache fast ``` #### 检查本地 DNS 和网络状况 除了调整软件包管理工具使用的服务器列表之外,还应该确认本机能够正常上网以及正确解析域名。可以通过尝试 ping 测试一些知名网站来验证这一点,比如百度或谷歌等。另外也可以通过 nslookup 工具查询指定域名为何 IP 地址,以此判断是否存在 DNS 解析方面的问题[^2]。 #### 安装额外组件辅助解决问题 有时安装某些扩展库可以帮助改善这种情况。例如,可以考虑安装 EPEL 扩展仓库或者 SCL 软件集合中的相关依赖项,这些可能会提供更好的兼容性和支持[^4]: ```bash sudo yum install epel-release sudo yum install -y centos-release-scl ``` 以上措施应当能有效缓解乃至彻底消除因无法解析 `mirrorlist.centos.org` 导致的各种麻烦。不过需要注意的是,不同环境下的具体情况会有所差异,因此建议根据实际需求灵活运用上述方法组合处理。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值