linux dnf配置文件,RedHat8.1配置本地dnf源

环境准备

RHEL8.1 不联网

REHL8.1 启动盘

RHEL8中默认使用的软件批量管理工具由原版本的yum换成了速度更快的dnf,原有的yum命令仅为dnf的软链接,当然依旧可以使用的。

一、挂载RHEL 8 ISO文件/安装DVD

要在RHEL 8服务器中挂载RHEL 8 ISO文件,请使用下面的mount命令

[root@linuxtechi-rhel8 ~]# mount -o loop rhel-8.0-x86_64-dvd.iso /opt/

RHEL 8安装DVD,请使用以下mount命令安装它

[root@linuxtechi-rhel8 ~]# mount /dev/sda4 /opt

这里注意如果你是使用ISO文件使用第一个命令,DVD版用第二个命令

二、将media.repo文件从安装目录到/etc/yum.repos.d/

[root@linuxtechi-rhel8 ~]# cp -v /opt/media.repo /etc/yum.repos.d/rhel8.repo

'/opt/media.repo' -> '/etc/yum.repos.d/rhel8.repo'

上权限:

[ root @ linuxtechi-rhel8〜]#chmod 644 /etc/yum.repos.d/rhel8.repo

三、在“ /etc/yum.repos.d/rhel8.repo”文件中添加存储库条目

编辑rhel8.repo文件并添加以下内容

[root@linuxtechi-rhel8 ~]# vi /etc/yum.repos.d/rhel8.repo

[InstallMedia-BaseOS]

name=Red Hat Enterprise Linux 8 - BaseOS

metadata_expire=-1

gpgcheck=1

enabled=1

baseurl=file:///opt/BaseOS/

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[InstallMedia-AppStream]

name=Red Hat Enterprise Linux 8 - AppStream

metadata_expire=-1

gpgcheck=1

enabled=1

baseurl=file:///opt/AppStream/

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

四、清理Yum / DNF和Subscription Manager缓存

root@linuxtechi-rhel8 ~]# dnf clean all

[root@linuxtechi-rhel8 ~]# subscription-manager clean

All local data removed

五、验证Yum / DNF是否正在从本地仓库获取软件包

[root@linuxtechi-rhel8 ~]# dnf repolist

Updating Subscription Management repositories.

Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 1:32:44 ago on Sat 11 May 2019 08:48:24 AM BST.

repo id repo name status

InstallMedia-AppStream Red Hat Enterprise Linux 8 - AppStream 4,672

InstallMedia-BaseOS Red Hat Enterprise Linux 8 - BaseOS 1,658

注意到了以上命令输出,收到警告消息“ 该系统未注册到Red Hat Subscription Management”。可以使用subscription-manager进行注册”,如果要在运行dnf / yum命令时禁止或阻止此消息,请编辑文件“ /etc/yum/pluginconf.d/subscription-manager.conf”,更改参数“ enabled = 1”到“ enabled = 0”

[ root @ linuxtechi-rhel8〜] #vi /etc/yum/pluginconf.d/subscription-manager.conf

[main]

enabled = 0

六、使用DNF / Yum安装软件包(测试)

[root@linuxtechi-rhel8 ~]# dnf install nginx

[root@linuxtechi-rhel8 ~]# dnf install nginx mariadb php -y

确认我们已经使用Installation DVD或ISO文件在RHEL 8服务器上成功配置了本地yum / dnf存储库

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值