故障案例:
[ root@sunboyytd ~ ] #yum install -y vim
已加载插件:fastestmirror
Determining fastest mirrors
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 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=<repoid> ...
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 <repoid>
or
subscription-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 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
故障原因:因丢失yum源,没有缓存在本地进而无法使之前安装的一些软件。
解决办法:
[ root@sunboyytd ~ ] #cd /etc/yum.repos.d
[ root@sunboyytd /etc/yum.repos.d ] #ll
总用量 40
-rw-r--r--. 1 root root 1664 10月 23 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 10月 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 10月 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 10月 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 10月 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 10月 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 10月 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 10月 23 2020 CentOS-x86_64-kernel.repo
[ root@sunboyytd /etc/yum.repos.d ] #rm -rf *
[ root@sunboyytd /etc/yum.repos.d ] #ll
总用量 0
[ root@sunboyytd /etc/yum.repos.d ] #curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2523 100 2523 0 0 6117 0 --:--:-- --:--:-- --:--:-- 6138
[ root@sunboyytd /etc/yum.repos.d ] #ls
CentOS-Base.repo
[ root@sunboyytd /etc/yum.repos.d ] #yum makecache
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/10): base/7/x86_64/group_gz | 153 kB 00:00:01
base/7/x86_64/primary_db FAILED
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
正在尝试其它镜像。
(2/10): extras/7/x86_64/other_db | 154 kB 00:00:00
(3/10): extras/7/x86_64/filelists_db | 305 kB 00:00:02
(4/10): base/7/x86_64/other_db | 2.6 MB 00:00:06
(5/10): updates/7/x86_64/filelists_db | 15 MB 00:00:09
(6/10): base/7/x86_64/primary_db | 6.1 MB 00:00:03
base/7/x86_64/filelists_db FAILED
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/d6d94c7d406fe7ad4902a97104b39a0d8299451832a97f31d71653ba982c955b-filelists.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
正在尝试其它镜像。
extras/7/x86_64/primary_db FAILED 45% [==================================== ] 602 kB/s | 28 MB 00:00:55 ETA
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/e12dbf10e94bc2b33b1f45e026559bc8685728b139dddae0654d96bc624c5602-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
正在尝试其它镜像。
updates/7/x86_64/primary_db FAILED 47% [=====================================- ] 739 kB/s | 29 MB 00:00:44 ETA
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/f19044932626155f0cd849e88972b84875fc85e3308b4d622844a911c4ef54d0-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
正在尝试其它镜像。
(7/10): extras/7/x86_64/primary_db | 253 kB 00:00:00
(8/10): base/7/x86_64/filelists_db | 7.2 MB 00:00:04
updates/7/x86_64/other_db FAILED 56% [============================================- ] 1.2 MB/s | 34 MB 00:00:22 ETA
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/14ff80eeb5b7c2c703cb151b97a17a9cec41fbe5c820b6e73a015d522e02bfe7-other.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
正在尝试其它镜像。
(9/10): updates/7/x86_64/other_db | 1.6 MB 00:00:00
(10/10): updates/7/x86_64/primary_db | 27 MB 00:00:20
元数据缓存已建立
建立好之后重新更新软件即可
#yum install -y lrzsz
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 lrzsz.x86_64.0.0.12.20-36.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=================================================================================================================================================================================================================
Package 架构 版本 源 大小
=================================================================================================================================================================================================================
正在安装:
lrzsz x86_64 0.12.20-36.el7 base 78 k
事务概要
=================================================================================================================================================================================================================
安装 1 软件包
总下载量:78 k
安装大小:181 k
Downloading packages:
警告:/var/cache/yum/x86_64/7/base/packages/lrzsz-0.12.20-36.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
lrzsz-0.12.20-36.el7.x86_64.rpm 的公钥尚未安装
lrzsz-0.12.20-36.el7.x86_64.rpm | 78 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
正在安装 : lrzsz-0.12.20-36.el7.x86_64 1/1
验证中 : lrzsz-0.12.20-36.el7.x86_64 1/1
已安装:
lrzsz.x86_64 0:0.12.20-36.el7
完毕!