首页 > 编程知识 正文

linux dnf配置文件RedHat81配置本地dnf源,linux配置本地yum源

时间:2023-05-05 16:16:43 阅读:213336 作者:2549

环境准备

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存储库

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。