一、报错如下
One of the configured repositories failed (CentOS-7 - Media),
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=c7-media ...
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 c7-media
or
subscription-manager repos --disable=c7-media
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=c7-media.skip_if_unavailable=true
failure: repodata/repomd.xml from c7-media: [Errno 256] No more mirrors to try.
file:///media/CentOS/repodata/repomd.xml: [Errno 14] curl#37 - “Couldn’t open file /media/CentOS/repodata/repomd.xml”
file:///media/cdrecorder/repodata/repomd.xml: [Errno 14] curl#37 - “Couldn’t open file /media/cdrecorder/repodata/repomd.xml”
file:///media/cdrom/repodata/repomd.xml: [Errno 14] curl#37 - “Couldn’t open file /media/cdrom/repodata/repomd.xml”
二、解决方式
1.重建缓存
yum cleam all
yum makecache
2.DNS的问题
# ls /etc/sysconfig/network-scripts/
# vim /etc/sysconfig/network-scripts/ifcfg-ens33
# service network restart
# cat /etc/resolv.conf 查下
# Generated by NetworkManager
nameserver 192.168.118.2
nameserver 114.114.114.114
不过本身可以连外网,这个应该不存在的
3、因为yum 寻包的顺序应该先是本地源,再寻网络源。
所以需要修改配置文件,解决办法就是把本地源关闭:
# vim /etc/yum.repos.d/CentOS-Media.repo
将里面的enabled=1改成enabled=0,然后保存退出。
完了之后执行 yum makecache,如果能重建缓存,说明解决了
查看yum源
# ll /etc/yum.repos.d/
总用量 60
-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 7月 7 06:33 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
-rw-r--r--. 1 root root 1919 6月 10 01:21 docker-ce.repo
-rw-r--r--. 1 root root 951 10月 3 2017 epel.repo
-rw-r--r--. 1 root root 1050 10月 3 2017 epel-testing.repo
-rw-r--r--. 1 root root 85 11月 30 2016 jenkins.repo
-rw-r--r-- 1 root root 897 7月 5 22:37 zabbix.repo
5、如果上面还不能解决,估计要重新安装yum了,附一个链接:
https://blog.csdn.net/shaoqiufeng/article/details/78785806