yum源被禁用的解决方法

1. 现场环境

[root@localhost yum.repos.d]# uname -r
3.10.0-862.el7.x86_64
[root@localhost yum.repos.d]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core) 

2. 报错信息

[root@localhost yum.repos.d]# yum -y install lrzsz
已加载插件: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]# yum repolist all
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
源标识                                                                           源名称                                                                                   状态
c7-media                                                                         CentOS-7 - Media                                                                         禁用
repolist: 0

#查看开启的yum源
[root@localhost yum.repos.d]# yum repolist enabled
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
repolist: 0

#查看关闭的yum源
[root@localhost yum.repos.d]# yum repolist disabled
已加载插件:fastestmirror
源标识                                                                             源名称                                                                                     
c7-media                                                                           CentOS-7 - Media                                                                           
repolist: 0

3. 解决方法

#创建一个新yum源
[root@localhost yum.repos.d]# cat CentOS-Base-163.repo 
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

[root@localhost yum.repos.d]# yum clean all && yum makecache

#尝试安装。如果出现如下报错
[root@localhost ~]# yum -y install yum
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
http://mirrors.163.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.163.com; 未知的错误"
正在尝试其它镜像。


 One of the configured repositories failed (CentOS-7 - Base - 163.com),
 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=base ...

     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 base
        or
            subscription-manager repos --disable=base

     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=base.skip_if_unavailable=true

failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try.
http://mirrors.163.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.163.com; 未知的错误"

#将数据写入如下文件
[root@localhost yum.repos.d]# cat /etc/resolv.conf
#nameserver
search localdomain
nameserver 8.8.8.8

[root@localhost yum.repos.d]# yum clean all && yum makecache

4. 其他

#阿里源
wget http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
如果您在运行 yum 命令时遇到 "储存库暂时禁用" 的错误消息,可能是由于某些储存库在一段时间内不可用或者出现了错误导致的。为了解决这个问题,您可以尝试以下步骤: 1. 检查储存库配置文件 打开储存库配置文件,通常位于 /etc/yum.repos.d/ 目录下,检查是否存在任何错误或者不完整的行。您可以备份该文件,然后手动编辑并修复任何错误。 2. 清除缓存 清除 yum 的缓存可能会解决该问题。您可以运行以下命令来清除 yum 缓存: ``` yum clean all ``` 3. 重新加载储存库 重新加载储存库可能会帮助您解决该问题。您可以运行以下命令来重新加载所有储存库: ``` yum makecache ``` 4. 禁用储存库 如果您确定某个储存库出现了问题,您可以禁用该储存库,以避免影响其他操作。您可以打开储存库配置文件并将该储存库的 enabled 选项设置为 0,例如: ``` [example] name=Example Repository baseurl=http://example.com/repo enabled=0 gpgcheck=1 ``` 5. 暂时更改储存库 如果您需要临时更改储存库,以便从其他可用安装软件包,可以使用 --disablerepo 选项禁用特定储存库,并使用 --enablerepo 选项启用其他储存库,例如: ``` yum --disablerepo=example --enablerepo=centos install package-name ``` 以上是一些可能有助于解决 "储存库暂时禁用" 错误消息的步骤。如果这些步骤无法解决问题,您可能需要等待储存库恢复正常运行或者联系储存库管理员获得支持。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值