2.7. 创建远程仓库

按照以下步骤,使用包含 DVD ISO 镜像内容的远程仓库为基于网络的安装创建安装源。可通过 HTTP 或 HTTPS 访问该安装源。

先决条件

  • 您有一个 Red Hat Enterprise Linux 9 安装 DVD/ISO 镜像。
  • 您有多个运行 Red Hat Enterprise Linux 的服务器。

2.7.1. 在 RHEL 上安装 Apache

这个过程将帮助您在 Red Hat Enterprise Linux 9 中安装 Apache。

先决条件

  • 您可以访问带有 Apache webserver 的存储库。

流程

  1. 安装 httpd 软件包

    # dnf install httpd
  2. 运行,然后启用 Apache webserver。这些命令也会在重启后启动 webserver。

    # systemctl enable httpd
    # systemctl start httpd
  3. 插入任何您可能拥有的网页文件。

    # echo Apache on RHEL {ProductNumber} > /var/www/html/index.html
  4. 更新防火墙。

    # firewall-cmd --add-service=http --permanent
    # firewall-cmd --add-service=http
  5. 访问网站。

    http://<the-apache-ip-address>
    
    http://<the-apache-hostname>

2.7.2. 创建远程仓库

多个 Red Hat Enterprise Linux 服务器可访问该网络中的单一 Red Hat Enterprise Linux 程序库。这需要一个正在运行的网页服务器,最有可能是 Apache。

先决条件

  • 您有一个 Red Hat Enterprise Linux 9 安装 DVD/ISO 镜像。
  • 您有多个运行 Red Hat Enterprise Linux 的服务器。

流程

  1. 挂载并复制下载的 DVD 的内容。

    mkdir /mnt/rhel{ProductNumber}
    mount -o loop,ro rhel-{ProductNumber}-x86_64-dvd.iso /mnt/rhel{ProductNumber}/
    cp -r /mnt/rhel{ProductNumber}/ /var/www/html/
    umount  /mnt/rhel{ProductNumber}

    下一步是在客户端执行,而不是在安装了 Apache 的服务器中执行。

  2. 为 BaseOS 和 AppStream 软件仓库创建一个 repo 文件。

    vi /etc/yum.repos.d/rhel_http_repo.repo
    
    [BaseOS_repo_http]
    name=RHEL_9_x86_64_HTTP BaseOS
    baseurl="http://myhost/rhel9/BaseOS"
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    
    [AppStream_repo_http]
    name=RHEL_9_x86_64_HTTP AppStream
    baseurl="http://myhost/rhel9/AppStream"
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    
    [root@localhost ~]# 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: 0:08:33 ago on Út 23. července 2019, 16:48:09 CEST.
    repo id                                                              repo name                                                                        status
    AppStream_repo_http                                                  RHEL_9_x86_64_HTTP AppStream                                                   4,672
    BaseOS_repo_http                                                     RHEL_9_x86_64_HTTP BaseOS                                                      1,658
    [root@localhost ~]#