您的位置:首页 > 教育 > 培训 > 商品展示页面设计模板_网业协同机制_免费创建个人博客网站_黄冈网站推广优化找哪家

商品展示页面设计模板_网业协同机制_免费创建个人博客网站_黄冈网站推广优化找哪家

2025/5/9 15:24:33 来源:https://blog.csdn.net/wel_006/article/details/147227018  浏览:    关键词:商品展示页面设计模板_网业协同机制_免费创建个人博客网站_黄冈网站推广优化找哪家
商品展示页面设计模板_网业协同机制_免费创建个人博客网站_黄冈网站推广优化找哪家

文章目录

  • 前言
  • 一、问题记录
  • 二、解决过程
    • 1.修改DNS无效
    • 2.指定镜像源
  • 总结


前言

今天有一个项目现场要在一个远程centos服务器上部署产品服务,发现能ping通百度,但是无法yum install 安装基础软件包,开始以为DNS服务器的问题,结果配置了也不行,最后通过指定镜像源的方式解决,解决过程记录下,方便后面遇到相同的问题快速解决。


一、问题记录

问题如下,能ping通百度,但是无法yum install :

[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (223.109.82.16) 56(84) bytes of data.
64 bytes from 223.109.82.16 (223.109.82.16): icmp_seq=1 ttl=52 time=13.6 ms
64 bytes from 223.109.82.16 (223.109.82.16): icmp_seq=2 ttl=52 time=13.6 ms
64 bytes from 223.109.82.16 (223.109.82.16): icmp_seq=3 ttl=52 time=13.0 ms
64 bytes from 223.109.82.16 (223.109.82.16): icmp_seq=4 ttl=52 time=15.5 ms
^C
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 13.046/13.991/15.574/0.956 ms
[root@localhost ~]# yum install net-tools -y
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
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; 未知的错误"One of the configured repositories failed (未知),and yum doesn't have enough cached data to continue. At this point the onlysafe 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 workingupstream. This is most often useful if you are using a newerdistribution release than is supported by the repository (and thepackages for the previous distribution release still work).3. Run the command with the repository temporarily disabledyum --disablerepo=<repoid> ...4. Disable the repository permanently, so yum won't use it by default. Yumwill then just ignore the repository until you permanently enable itagain or use --enablerepo for temporary usage:yum-config-manager --disable <repoid>orsubscription-manager repos --disable=<repoid>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 muchslower). If it is a very temporary problem though, this is often a nicecompromise:yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=trueCannot find a valid baseurl for repo: base/7/x86_64

二、解决过程

1.修改DNS无效

vi /etc/resolv.conf:
添加公共 DNS 服务器地址:
nameserver 8.8.8.8

[root@localhost ~]# vi /etc/resolv.conf 
[root@localhost ~]# ping mirrorlist.centos.org
ping: mirrorlist.centos.org: 未知的名称或服务
[root@localhost ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
#nameserver 192.168.1.1
nameserver 8.8.8.8
[root@localhost ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=53 time=46.0 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=53 time=46.2 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=53 time=45.9 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=53 time=46.1 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=53 time=48.9 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=53 time=46.1 ms
^C
--- 8.8.8.8 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5005ms
rtt min/avg/max/mdev = 45.925/46.569/48.998/1.125 ms
[root@localhost ~]# nslookup mirrorlist.centos.org 8.8.8.8
-bash: nslookup: 未找到命令
[root@localhost ~]# yum install bind-utils
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
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; 未知的错误"

可以看到在该环境下添加公共 DNS 服务器地址,虽然能ping通8.8.8.8,但是仍然解决不了在线yum install 安装工具的问题。

2.指定镜像源

由于无法解析 mirrorlist.centos.org,可以直接指定一个可用的镜像源。先备份原来的 CentOS-Base.repo 文件:

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

接着从阿里云下载新的 CentOS-Base.repo 文件:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

此处如果简单的用wget 命令也会无法执行:

[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
-bash: wget: 未找到命令
[root@localhost yum.repos.d]# yum install wget
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
There are no enabled repos.Run "yum repolist all" to see the repos you have.To enable Red Hat Subscription Management repositories:subscription-manager repos --enable <repo>To enable custom repositories:yum-config-manager --enable <repo>
[root@localhost yum.repos.d]# ls

直接从windows机器上下载了一个Centos-7.repo,然后放到/etc/yum.repos.d/目录下
在这里插入图片描述

[root@localhost yum.repos.d]# ls -l
总用量 36
-rw-r--r--. 1 root root 2523 414 16:28 Centos-7.repo
-rw-r--r--. 1 root root 1664 1123 2018 CentOS-Base.repo.backup
-rw-r--r--. 1 root root 1309 1123 2018 CentOS-CR.repo
-rw-r--r--. 1 root root  649 1123 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 1123 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 1123 2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 1123 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 1123 2018 CentOS-Vault.repo

更新缓存:

yum clean all
yum makecache

再次尝试安装:

[root@localhost yum.repos.d]# yum install net-tools -y
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 net-tools.x86_64.0.2.0-0.25.20131004git.el7 将被 安装
--> 解决依赖关系完成依赖关系解决==============================================================================================================================================================================================================================================================================Package                                                         架构                                                         版本                                                                           源                                                          大小
==============================================================================================================================================================================================================================================================================
正在安装:net-tools                                                       x86_64                                                       2.0-0.25.20131004git.el7                                                       base                                                       306 k事务概要
==============================================================================================================================================================================================================================================================================
安装  1 软件包总下载量:306 k
安装大小:917 k
Downloading packages:
警告:/var/cache/yum/x86_64/7/base/packages/net-tools-2.0-0.25.20131004git.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY                                                                                               ]  0.0 B/s |    0 B  --:--:-- ETA 
net-tools-2.0-0.25.20131004git.el7.x86_64.rpm 的公钥尚未安装
net-tools-2.0-0.25.20131004git.el7.x86_64.rpm                                                                                                                                                                                                          | 306 kB  00:00:00     
从 http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5来自       : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction正在安装    : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                                                                                                                                                 1/1 验证中      : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                                                                                                                                                 1/1 已安装:net-tools.x86_64 0:2.0-0.25.20131004git.el7                                                                                                                                                                                                                                 完毕!

问题解决!


总结

这就是今天的一次问题解决,虽然是小问题,但是每次记录下,供下次出现问题时参考,能省不少时间,以前解决过很多的问题,当时觉得很清楚,觉得没什么好记录的,但时间长了又忘了,所以不管问题大小,及时总结记录是一个很好的习惯,集少成多。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com