[debug]-centos7使用yum安装包,报错Loaded plugins:fastestmirror...No package x available Error: Nothing to do

1.问题描述

yum服务挂了,安装任何包都会报错

# 执行命令
$ yum install xxx
# 报错
Loaded plugins: fastestmirror, refresh-packagekit, security 
Loading mirror speeds from cache
No package xxx available. 
Error: Nothing to do

2.解决

测试网络是否接通

ping baidu.com
# 有返回即可

如果显示没有连接的话,就说明没网,也就无法使用yum 命令。

3.解决

网络通的情况下,yum源可能有问题,需要更换一下yum源

  1. 备份一下设置源的文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  1. 下载新的yum设置下载源的文件
    CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

或者

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  1. 生成缓存
yum clean all
yum makecache

4)装一下 epel 源

EPEL(Extra Packages for Enterprise Linux)是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS等提供高质量软件包的项目。装上了 EPEL,就像在 Fedora 上一样,可以通过 yum install 软件包名,即可安装很多以前需要编译安装的软件、常用的软件或一些比较流行的软件,比如现在流行的nginx、htop、ncdu、vnstat等等,都可以使用EPEL很方便的安装更新。

yum install epel-release

之后再使用 yum install xxx 一切正常

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值