🍣

Creating a Mirror Repository(ミラーリポジトリの作成)

に公開

Creating a Mirror Repository

1. Install Required Packages

dnf install -y dnf-utils createrepo httpd

2. Create Directories and Set Permissions

mkdir -p /data01/repos/{baseos,appstream,codeready,microsoft}
chown -R root:apache /data01/repos
chmod -R 755 /data01/repos

3. Synchronize Repositories (Using dnf reposync)

reposync --repo=rhel-9-for-x86_64-baseos-eus-rhui-rpms \
  --download-path=/data01/repos/baseos

reposync --repo=rhel-9-for-x86_64-appstream-eus-rhui-rpms \
  --download-path=/data01/repos/appstream

reposync --repo=codeready-builder-for-rhel-9-x86_64-eus-rhui-rpms \
  --download-path=/data01/repos/codeready -x dotnet-sdk*

reposync --repo=rhui-microsoft-azure-rhel9-eus \
  --download-path=/data01/repos/microsoft

Note:
To download packages from the four repositories listed above, approximately 512 GB of disk space is required (as of April 2025).
In the example provided, the download of dotnet-sdk packages is excluded to save space.
Even with this exclusion, 147 GB of disk space is still needed.

4. Generate Metadata (Using createrepo)

createrepo /data01/repos/microsoft/rhui-microsoft-azure-rhel9-eus
createrepo /data01/repos/baseos/rhel-9-for-x86_64-baseos-eus-rhui-rpms
createrepo /data01/repos/appstream/rhel-9-for-x86_64-appstream-eus-rhui-rpms
createrepo /data01/repos/codeready/codeready-buiilder-for-rhel-9-x86_64-eus-rhui-rpms

5. Configure Apache (Serve /data01/repos via HTTP)

apache
Alias /repos /data01/repos

<Directory "/data01/repos">
    Options -Indexes -ExecCGI -FollowSymLinks
    AllowOverride None
    Require all granted   # Optionally restrict by IP: Require ip 192.168.0.0/24
</Directory>

6. Start Apache

systemctl enable --now httpd

7. Sample .repo File for Clients (HTTP Access)

/etc/yum.repos.d/local-rhui.repo

[local-baseos]
name=Local RHUI BaseOS
baseurl=http://<server-ip>/repos/baseos/rhel-9-for-x86_64-baseos-eus-rhui-rpms
enabled=1
gpgcheck=0


[local-appstream]
name=Local RHUI AppStream
baseurl=http://<server-ip>/repos/appstream/rhel-9-for-x86_64-appstream-eus-rhui-rpms
enabled=1
gpgcheck=0

[local-codeready]
name=Local RHUI codeready
baseurl=http://<server-ip>/repos/codeready/codeready-builder-for-rhel-9-x86_64-eus-rhui-rpms
enabled=1
gpgcheck=0


[local-azure]
name=Local RHUI Azure RHEL9
baseurl=http://<server-ip>/repos/microsoft/rhui-microsoft-azure-rhel9-eus/
enabled=1
gpgcheck=0

7. Clear dnf cache

dnf clean all

Discussion