Some of you might share the following use case: You need (or want) to mirror repos to provide packages for the hosts on your LAN that are not connected to the internet, and therefore cannot access the upstream repos directly. In this article, I explain how to accomplish this task easily by using reposync, which is shipped with your Red Hat Enterprise Linux (RHEL) 7 or Red Hat Enterprise Linux 8 subscription.
Before we get started, I would like to point out the important requirements. You need a valid subscription for every repo you would like to mirror because your mirror server can only sync those repos that are included in its own subscription. All of your other hosts that will use this mirror need to have a valid subscription, too.
If you have any questions about subscriptions, please take a look at the following URLs: the Red Hat subscription model FAQ and the Red Hat subscription service overview.
Setting up mirrored repos for Red Hat Enterprise Linux 7
To start, you’ll need to choose the web server that will serve the mirrored repos to your LAN. Then, if you’re using Red Hat Enterprise Linux 7, then to create a basic repo you have to start by installing createrepo. Don’t worry, this tool is included in your subscription, too. Install it on your web server with the following:
# yum install yum-utils createrepo
Next, you need the repository ID for the repo you would like to sync. Run yum repolist, and you’ll find the repo ID in the output’s first column:
$ yum repolist
Loaded plugins: langpacks, nvidia, product-id, search-disabled-repos, subscription-
: manager
repo id repo name status
rhel-7-server-optional-rpms/7Server/x86_64 Red Hat Enterprise Linux 7 Server - O 19.490
rhel-7-server-rpms/7Server/x86_64 Red Hat Enterprise Linux 7 Server (RP 26.766
virtualbox/7Server/x86_64 Oracle Linux / RHEL / CentOS-7Server 77
In this case, rhel-7-server-rpms is the ID for the standard Red Hat Enterprise Linux 7 repo. You can get a complete list of repos your subscription has access to with the command:
$ sudo subscription-manager repos --list
You’ll find the repo ID in there, too.
For example, to sync the packages from the rhel-7-server-rpms repo and create a basic local repository, execute the following commands:
# reposync --gpgcheck -l --repoid=rhel-7-server-rpms --download_path=/var/www/html # Sync RPMS
# cd /var/www/html/rhel-7-server-rpms
# createrepo -v /var/www/html/rhel-7-server-rpms # Create the repo
Setting up mirrored repos for Red Hat Enterprise Linux 8
For Red Hat Enterprise Linux 8, this process is even easier. You only need the reposync command:
# reposync -p <download-path> --download-metadata --repo=<repo id>
The createrepo command is not needed anymore because reposync downloads everything, including the repodata.
Sharing the local repository
Once the packages are fetched and the local repo is created using either of these methods, the local repository can be distributed among the offline/disconnected systems using a simple web server, FTP, or NFS. The following knowledgebase articles provide the necessary information regarding your choice of distribution:
For more sophisticated setup than described in this article, consider using Red Hat Satellite.
[ Want to try out Red Hat Enterprise Linux? Download it now for free. ]
Über den Autor
Jörg has been a Sysadmin for over ten years now. His fields of operation include Virtualization (VMware), Linux System Administration and Automation (RHEL), Firewalling (Forcepoint), and Loadbalancing (F5). He is a member of the Red Hat Accelerators Community and author of his personal blog at https://www.my-it-brain.de.
Ähnliche Einträge
Behind the scenes of RHEL 10, part 3
Alliander modernises its electricity grid with Red Hat for long-term reliability in balance with rapid innovation
The Overlooked Operating System | Compiler: Stack/Unstuck
Linux, Shadowman, And Open Source Spirit | Compiler
Nach Thema durchsuchen
Automatisierung
Das Neueste zum Thema IT-Automatisierung für Technologien, Teams und Umgebungen
Künstliche Intelligenz
Erfahren Sie das Neueste von den Plattformen, die es Kunden ermöglichen, KI-Workloads beliebig auszuführen
Open Hybrid Cloud
Erfahren Sie, wie wir eine flexiblere Zukunft mit Hybrid Clouds schaffen.
Sicherheit
Erfahren Sie, wie wir Risiken in verschiedenen Umgebungen und Technologien reduzieren
Edge Computing
Erfahren Sie das Neueste von den Plattformen, die die Operations am Edge vereinfachen
Infrastruktur
Erfahren Sie das Neueste von der weltweit führenden Linux-Plattform für Unternehmen
Anwendungen
Entdecken Sie unsere Lösungen für komplexe Herausforderungen bei Anwendungen
Virtualisierung
Erfahren Sie das Neueste über die Virtualisierung von Workloads in Cloud- oder On-Premise-Umgebungen