RHEL8 创建本地YUM存储库

yum 的好处及本地yum的好处不在本文讨论范畴,本文针对rhel8中的新功能yum做简要介绍和配置,在 RHEL 8中分为两个存储库:

  • BaseOS
  • 应用程序流(AppStream)

BaseOS中的软件包旨在提供底层操作系统功能的核心集,为所有类型的安装提供基础。Application Stream中的包包括用户空间应用程序,运行时语言和数据库,以支持各种工作负载和用例。

1.创建本地yum源

可以使用repo包创建存储库的源,也可以将DVD mount 到本地目录。

1.1. 创建挂载目录

mkdir /mnt/dvd

1.2 挂载ISO文件

将本地ISO文件挂载到挂载目录/mnt/dvd中

mount /opt/RHEL-8.0-20181113.1-Server-x86_64-dvd1.iso /mnt/dvd/

永久挂载ISO包

vim /etc/fstab 

# 添加ISO包路径到fstab 文件

/opt/RHEL-8.0-20181113.1-Server-x86_64-dvd1.iso /mnt/dvd iso9660 loop 0 0

1.3 创建repo文件

在/etc/yum.repos.d目录下创建一个名为local.repo的repo文件。

vi /etc/yum.repos.d/local.repo

Base OS
[LocalRepo_BaseOS]
name=LocalRepo_BaseOS
baseurl=file:///mnt/dvd/BaseOS
gpgcheck=0
gpgkey=file:///mnt/dvd/BaseOS/RPM-GPG-KEY-redhat-release
enabled=1

App Stream
[LocalRepo_AppStream]
name=LocalRepository_AppStream
baseurl=file:///mnt/dvd/AppStream
enabled=1
gpgcheck=0
gpgkey=file:///mnt/dvd/AppStream/RPM-GPG-KEY-redhat-beta

参数说明:

[LocalRepo]  # 该部分的名称
name       # 存储库的名称
baseurl         # 包裹的位置
enabled             # 启用存储库
gpgcheck          # 启用安全安装(gpgcheck是可选的(如果设置gpgcheck = 0,则无需提及gpgkey)
gpgkey              # 密钥的位置

2. 从本地yun安装软件包

2.1 清除本地缓存

[root@localhost ~]# yum clean all
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.
0 files removed

2.2. 重建本地缓存

[root@localhost ~]# yum makecache
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.
localrepository_appstream                                                                                                        0.0  B/s |   0  B     00:00    
local dvd yum                                                                                                                    0.0  B/s |   0  B     00:00    
Failed to synchronize cache for repo 'local_appstream', ignoring this repo.
Failed to synchronize cache for repo 'yum_local', ignoring this repo.
Metadata cache created.

2.3. 从本地yum 安装软件包

[root@localhost yum.repos.d]# yum install httpd
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: 0:00:52 ago on Sat 28 Sep 2019 05:44:38 PM EDT.
Dependencies resolved.
=======================================================================================================================================================================================================================================================================
 Package                                                        Arch                                               Version                                                                           Repository                                                   Size
=======================================================================================================================================================================================================================================================================
Installing:
 httpd                                                          x86_64                                             2.4.37-10.module+el8+2764+7127e69e                                                local_appstream                                             1.4 M
Installing dependencies:
 apr                                                            x86_64                                             1.6.3-9.el8                                                                       local_appstream                                             125 k
 apr-util                                                       x86_64                                             1.6.1-6.el8                                                                       local_appstream                                             105 k
 httpd-filesystem                                               noarch                                             2.4.37-10.module+el8+2764+7127e69e                                                local_appstream                                              34 k
 httpd-tools                                                    x86_64                                             2.4.37-10.module+el8+2764+7127e69e                                                local_appstream                                             101 k
 mod_http2                                                      x86_64                                             1.11.3-1.module+el8+2443+605475b7                                                 local_appstream                                             156 k
 redhat-logos-httpd                                             noarch                                             80.7-1.el8                                                                        yum_local                                                    25 k
Installing weak dependencies:
 apr-util-bdb                                                   x86_64                                             1.6.1-6.el8                                                                       local_appstream                                              25 k
 apr-util-openssl                                               x86_64                                             1.6.1-6.el8                                                                       local_appstream                                              27 k
Enabling module streams:
 httpd                                                                                                             2.4                                                                                                                                                

Transaction Summary
=======================================================================================================================================================================================================================================================================
Install  9 Packages

Total size: 2.0 M
Installed size: 5.4 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                                               1/1 
  Installing       : apr-1.6.3-9.el8.x86_64                                                                                                                                                                                                                        1/9 
  Running scriptlet: apr-1.6.3-9.el8.x86_64                                                                                                                                                                                                                        1/9 
  Installing       : apr-util-bdb-1.6.1-6.el8.x86_64                                                                                                                                                                                                               2/9 
  Installing       : apr-util-openssl-1.6.1-6.el8.x86_64                                                                                                                                                                                                           3/9 
  Installing       : apr-util-1.6.1-6.el8.x86_64                                                                                                                                                                                                                   4/9 
  Running scriptlet: apr-util-1.6.1-6.el8.x86_64                                                                                                                                                                                                                   4/9 
  Installing       : httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86_64                                                                                                                                                                                         5/9 
  Installing       : redhat-logos-httpd-80.7-1.el8.noarch                                                                                                                                                                                                          6/9 
  Running scriptlet: httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch                                                                                                                                                                                    7/9 
  Installing       : httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch                                                                                                                                                                                    7/9 
  Installing       : mod_http2-1.11.3-1.module+el8+2443+605475b7.x86_64                                                                                                                                                                                            8/9 
  Installing       : httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64                                                                                                                                                                                               9/9 
  Running scriptlet: httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64                                                                                                                                                                                               9/9 
  Verifying        : apr-1.6.3-9.el8.x86_64                                                                                                                                                                                                                        1/9 
  Verifying        : apr-util-1.6.1-6.el8.x86_64                                                                                                                                                                                                                   2/9 
  Verifying        : apr-util-bdb-1.6.1-6.el8.x86_64                                                                                                                                                                                                               3/9 
  Verifying        : apr-util-openssl-1.6.1-6.el8.x86_64                                                                                                                                                                                                           4/9 
  Verifying        : httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64                                                                                                                                                                                               5/9 
  Verifying        : httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch                                                                                                                                                                                    6/9 
  Verifying        : httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86_64                                                                                                                                                                                         7/9 
  Verifying        : mod_http2-1.11.3-1.module+el8+2443+605475b7.x86_64                                                                                                                                                                                            8/9 
  Verifying        : redhat-logos-httpd-80.7-1.el8.noarch                                                                                                                                                                                                          9/9 
Installed products updated.

Installed:
  httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64        apr-util-bdb-1.6.1-6.el8.x86_64                     apr-util-openssl-1.6.1-6.el8.x86_64   apr-1.6.3-9.el8.x86_64  apr-util-1.6.1-6.el8.x86_64  httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch 
  httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86_64  mod_http2-1.11.3-1.module+el8+2443+605475b7.x86_64  redhat-logos-httpd-80.7-1.el8.noarch 

Complete!
[root@localhost yum.repos.d]# 

配置完成,如有问题,请留言交流!

 

转载于:https://www.cnblogs.com/miaocbin/p/11606055.html

你可能感兴趣的:(RHEL8 创建本地YUM存储库)