https://onitroad.com 更多教程

检查确认

验证我们是否可以从刚刚创建的存储库中列出包。

# yum  --noplugins list
# yum repolist -v
    [snip]
    ISO-Server                                               | 4.1 kB     00:00     
    (1/2): ISO-Server/group_gz                                 | 134 kB   00:00     
    (2/2): ISO-Server/primary_db                               | 3.4 MB   00:00     
    Setting up Package Sacks
    pkgsack time: 0.001
    Repo-id      : ISO-Server
    Repo-name    : RHEL 7 Server DVD
    Repo-revision: 1424360184
    Repo-updated : Thu Nov 19 10:36:27 2017
    Repo-pkgs    : 4,371
    Repo-size    : 3.2 G
    Repo-baseurl : file:///mnt/
    Repo-expire  : 21,600 second(s) (last: Fri Jan 10 12:55:47 2017)
    Repo-filename: ///etc/yum.repos.d/rhel7.repo
    repolist: 4,371
CentOS/RHEL 7:如何使用ISO光盘设置 yum 存储库

yum 是用于从官方 Red Hat 软件存储库以及其他第三方存储库获取、安装、删除、查询和管理 Red Hat Enterprise Linux RPM 软件包的主要工具。
下面的帖子描述了使用本地安装的 RHEL 7 DVD iso 作为 yum 存储库的分步过程。

  1. 将 RHEL 7 安装介质 ISO 挂载到某个目录。
    例如 /mnt :
# mount -o loop rhel7.iso /mnt

另请阅读:Linux/UNIX:如何挂载 iso 文件

  1. 从挂载目录 /mnt /etc/yum.repos.d/ 复制 media.repo 文件,并将其命名为 rhel7.repo 。
# cp /mnt/media.repo /etc/yum.repos.d/rhel7.repo
  1. 为存储库文件授予适当的权限。
# chmod 644 /etc/yum.repos.d/rhel7.repo
  1. 修改repo文件,将参数gpgcheck=0改为gpgcheck=1,在同一个文件中添加以下3行。
enabled=1
baseurl=file:///mnt/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  1. 完成所有更改后,最终的 repo 文件将如下所示。
    (请注意,media-id 可能因使用 DVD 的 RHEL 版本而异)
[InstallMedia]
name=DVD for Red Hat Enterprise Linux 7.3 Server
mediaid=9859238196.834790
metadata_expire=-1
gpgcheck=1
cost=500
enabled=1
baseurl=file:///mnt/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  1. 确保通过 yum clean all 和 subscription-manager clean once 清除相关缓存。
# yum clean all
# subscription-manager clean
日期:2020-09-17 00:12:05 来源:oir作者:oir