【Error: No available modular metadata for modular package】

*Redhat 8 yum安装报错Error: No available modular metadata for modular package

红帽8,默认是不可以使用yum的,dnf就相当于yum,由于一直使用yum习惯了,所以可以通过命令安装yum

dnf  install yum -y

如果不想安装,可以直接使用dnf,和yum用法是一样的!
在这里插入图片描述
在公司测试环境使用yum安装时出现这个报错(测试环境是不可以访问外网的),我在网上找了好多关于这个报错的资料,但是都不适用,后来经过不断地尝试,在自己本地虚拟机上做实验(自己电脑可以访问外网),最后锁定是repo源的问题,我这里是使用的国内的阿里源,写出来分享一下。
方法一、二适用于可以访问外网的情况

方法一:

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

方法二:

在浏览器输入https://mirrors.aliyun.com/repo/Centos-8.repo直接下载之后放在/etc/yum.repos.d/下。
也可以直接粘贴以下内容使用

# 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 - mirrors.aliyun.com
#failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
#failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
#failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
[PowerTools]
name=CentOS-$releasever - PowerTools - mirrors.aliyun.com
#failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official


[AppStream]
name=CentOS-$releasever - AppStream - mirrors.aliyun.com
#failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

yum clean all
yum makecache

在这里插入图片描述
问题完美解决!
方法三:

适用于公司电脑不能直接访问外网,通过在DMZ区搭建nexus3实现代理内网机器去外网拉取镜像,nexus默认端口为8081,可以在配置文件中修改
(Nexus3的搭建可参考网上文章,或后续有时间我会更新,需要注意的是,需要防火墙配置设置可以访问的URL,例如国内的阿里源,清华源等。)
将上述下载的repo源url进行替换即可
例:

[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://x.x.x.x:8081/repository/yum-proxy-aliyun/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=http://x.x.x.x:8081/repository/yum-proxy-aliyun/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://x.x.x.x:8081/repository/yum-proxy-aliyun/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=http://x.x.x.x:8081/repository/yum-proxy-aliyun/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://x.x.x.x:8081/repository/yum-proxy-aliyun/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=http://x.x.x.x:8081/repository/yum-proxy-aliyun/centos/RPM-GPG-KEY-CentOS-Official
 
[PowerTools]
name=CentOS-$releasever - PowerTools - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://x.x.x.x:8081/repository/yum-proxy-aliyun/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=http://x.x.x.x:8081/repository/yum-proxy-aliyun/centos/RPM-GPG-KEY-CentOS-Official


[AppStream]
name=CentOS-$releasever - AppStream - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://x.x.x.x:8081/repository/yum-proxy-aliyun/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=http://x.x.x.x:8081/repository/yum-proxy-aliyun/centos/RPM-GPG-KEY-CentOS-Official

有问题欢迎留言探讨!

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值