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. ]
À propos de l'auteur
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.
Plus de résultats similaires
More than meets the eye: Behind the scenes of Red Hat Enterprise Linux 10 (Part 4)
Why should your organization standardize on Red Hat Enterprise Linux today?
The Overlooked Operating System | Compiler: Stack/Unstuck
Linux, Shadowman, And Open Source Spirit | Compiler
Parcourir par canal
Automatisation
Les dernières nouveautés en matière d'automatisation informatique pour les technologies, les équipes et les environnements
Intelligence artificielle
Actualité sur les plateformes qui permettent aux clients d'exécuter des charges de travail d'IA sur tout type d'environnement
Cloud hybride ouvert
Découvrez comment créer un avenir flexible grâce au cloud hybride
Sécurité
Les dernières actualités sur la façon dont nous réduisons les risques dans tous les environnements et technologies
Edge computing
Actualité sur les plateformes qui simplifient les opérations en périphérie
Infrastructure
Les dernières nouveautés sur la plateforme Linux d'entreprise leader au monde
Applications
À l’intérieur de nos solutions aux défis d’application les plus difficiles
Virtualisation
L'avenir de la virtualisation d'entreprise pour vos charges de travail sur site ou sur le cloud