I have already written an article to download an individual rpm along with all it's dependencies, in this article I will share the steps to download entire repository from CentOS / RHEL 7 to your local Linux node. To download the repository you will need one time active internet access.
PlayNext
Mute
Current Time 0:00
/
Duration 0:00
Fullscreen
Backward Skip 10sPlay VideoForward Skip 10s
Once the rpms are downloaded the you can configure a local repository with these rpms for offline usage. Although downloading (syncing) the entire repository content to local Linux node may take some time depending upon your internet speed and the content of the repository.

I have a node which is in a private network and does not has access to the Internet so I always have to go through a lot of trouble in case I have to install some additional rpm with multiple dependencies. Using this method I have created a local repository in my private network which helps me download required rpm without internet.
Install the required packages
First install the yum-utils and createrepo packages on the system which will be used for the syncing purpose:
NOTE:
On RHEL system you must have an active subscription to RHN or you can configure a local offline repository using which "yum" package manager can install the provided rpm and it's dependencies.
bash
# yum install yum-utils createrepo
Download entire repository from CentOS 7
On CentOS unlike RHEL you do not need to perform any additional subscription related activity to get the access to their repository. As soon as you install CentOS, you will find below list of repo files under /etc/yum.repos.d
bash
[root@openstack yum.repos.d]# ll total 40 -rw-r--r--. 1 root root 1664 Aug 30 2017 CentOS-Base.repo -rw-r--r--. 1 root root 1309 Aug 30 2017 CentOS-CR.repo -rw-r--r--. 1 root root 649 Aug 30 2017 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 314 Aug 30 2017 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 Aug 30 2017 CentOS-Media.repo -rw-r--r--. 1 root root 1331 Aug 30 2017 CentOS-Sources.repo -rw-r--r--. 1 root root 3830 Aug 30 2017 CentOS-Vault.repo
Step-by-Step: RHEL/CentOS 8 installation with screenshots
Not all of these repositories will be in enable state, some of them may be in disable state. To check the currently active repos use below command
bash
# yum repolist Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net repo id repo name status base/7/x86_64 CentOS-7 - Base 9,911 extras/7/x86_64 CentOS-7 - Extras 432 openstack-pike/x86_64 OpenStack Pike Repository 2,812 rdo-qemu-ev/x86_64 RDO CentOS-7 - QEMU EV 59 updates/7/x86_64 CentOS-7 - Updates 1,540 repolist: 14,754
HINT:
ADVERTISEMENT
In RHEL 8 reposync is part of dnf-plugins-core rpm. The new syntax to download entire repository in RHEL 8 is
bash
[root@rhel-8 ~]# dnf reposync --repoid=<repo_id> -p=<download_path>
To download (or sync) a repository on CentOS/RHEL 7 use the below command
bash
# reposync --gpgcheck -l --repoid=<repo_id> --download_path=<path>
Here replace repo_id with the ID of the repository you wish to sync locally, for example in the below command I am syncing extras repo and downloading the rpms to /tmp
bash
# reposync --gpgcheck -l --repoid=extras --download_path=/tmp
NOTE:
In the targeted directory, there will be a new directory named after the Repository ID. Inside there is all the packages
To have access to the group data for the newly synced repo, please run the createrepo command as follows:
bash
# cd /tmp/<channel-id> # createrepo -v /tmp/<channel-id>/
For example:
bash
# cd /tmp/extras # createrepo /tmp/extras
Download entire repository from RHEL 7
First of all on RHEL 7 you must first register your node to the Red Hat Network.
ADVERTISEMENT
bash
# subscription-manager register Registering to: subscription.rhsm.redhat.com:443/subscription Username: deepak Password: The system has been registered with ID: 04bbc67c-f45c-47e9-9bec-122e8cd10c9d
Next check the list of entitlements to your ID
bash
# subscription-manager list --available --all
Once you know which entitlement suits your requirement, then attach the POOL ID for your system
bash
# subscription-manager attach --pool=<pool_id>
Next enable all the repositories you wish to use. You can check all the subscribed repositories using the below command
bash
# yum repolist all
Once you have the repo id which you wish to download use the same command as we use with CentOS 7
Check CPU Utilization in Linux Like a PRO [7 Tools]
Syntax:
bash
# reposync --gpgcheck -l --repoid=<repo_id> --download_path=<path> --downloadcomps --download-metadata
Here replace repo_id with the ID of the repository you wish to sync locally, for example in the below command I am syncing extras repo and downloading the rpms to /tmp
bash
# reposync --gpgcheck -l --repoid=rhel-7-server-openstack-10-devtools-rpms --download_path=/tmp --downloadcomps --download-metadata
NOTE:
In the targeted directory, there will be a new directory named after the Repository ID. Inside there is all the packages
To have access to the group data for the newly synced repo, please run the createrepo command as follows:
bash
# cd /var/www/html/<channel-id> # createrepo -v /var/www/html/<channel-id>/ -g comps.xml
For example:
bash
# cd /var/www/html/rhel-7-server-openstack-10-devtools-rpms # createrepo -v /var/www/html/rhel-7-server-openstack-10-devtools-rpms/ -g comps.xml Spawning worker 0 with 1 pkgs Spawning worker 1 with 1 pkgs Spawning worker 2 with 1 pkgs Spawning worker 3 with 1 pkgs Spawning worker 4 with 1 pkgs Spawning worker 5 with 1 pkgs Spawning worker 6 with 1 pkgs Spawning worker 7 with 1 pkgs Spawning worker 8 with 1 pkgs Spawning worker 9 with 1 pkgs Spawning worker 10 with 1 pkgs Spawning worker 11 with 1 pkgs Spawning worker 12 with 0 pkgs Spawning worker 13 with 0 pkgs Spawning worker 14 with 0 pkgs Spawning worker 15 with 0 pkgs Spawning worker 16 with 0 pkgs Spawning worker 17 with 0 pkgs Spawning worker 18 with 0 pkgs Spawning worker 19 with 0 pkgs Spawning worker 20 with 0 pkgs Spawning worker 21 with 0 pkgs Spawning worker 22 with 0 pkgs Spawning worker 23 with 0 pkgs Spawning worker 24 with 0 pkgs Spawning worker 25 with 0 pkgs Spawning worker 26 with 0 pkgs Spawning worker 27 with 0 pkgs Spawning worker 28 with 0 pkgs Spawning worker 29 with 0 pkgs Spawning worker 30 with 0 pkgs Spawning worker 31 with 0 pkgs Worker 0: reading Packages/dpdk-16.11-3.el7fdp.x86_64.rpm Worker 1: reading Packages/openstack-packstack-9.0.0-3.el7ost.noarch.rpm Worker 2: reading Packages/openstack-packstack-9.0.1-3.el7ost.noarch.rpm Worker 3: reading Packages/openstack-packstack-9.0.3-4.el7ost.noarch.rpm Worker 4: reading Packages/openstack-packstack-9.0.3-5.el7ost.noarch.rpm Worker 5: reading Packages/openstack-packstack-puppet-9.0.0-3.el7ost.noarch.rpm Worker 6: reading Packages/openstack-packstack-puppet-9.0.1-3.el7ost.noarch.rpm Worker 7: reading Packages/openstack-packstack-puppet-9.0.3-4.el7ost.noarch.rpm Worker 8: reading Packages/openstack-packstack-puppet-9.0.3-5.el7ost.noarch.rpm Worker 9: reading Packages/openstack-utils-2016.1-1.el7ost.noarch.rpm Worker 10: reading Packages/openvswitch-test-2.9.0-19.el7fdp.1.noarch.rpm Worker 11: reading Packages/openvswitch-test-2.9.0-56.el7fdp.noarch.rpm Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Starting other db creation: Sun Oct 7 19:23:07 2018 Ending other db creation: Sun Oct 7 19:23:07 2018 Starting filelists db creation: Sun Oct 7 19:23:07 2018 Ending filelists db creation: Sun Oct 7 19:23:07 2018 Starting primary db creation: Sun Oct 7 19:23:07 2018 Ending primary db creation: Sun Oct 7 19:23:07 2018 Sqlite DBs complete
Let us validate our repository
NOTE:I have configured an offline repository using http server with below content
bash
[rhel-7-server-openstack-10-devtools-rpms] name=rhel-7-server-openstack-10-devtools-rpms baseurl=http://192.168.122.1/repo/rhel-7-server-openstack-10-devtools-rpms/ gpgcheck=0 enabled=1
bash
# yum repolist all Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. repo id repo name status rhel-7-server-extras-rpms rhel-7-server-extras-rpms enabled: 814 rhel-7-server-openstack-10-devtools-rpms rhel-7-server-openstack-10-devtools-rpms enabled: 12 rhel-7-server-rh-common-rpms rhel-7-server-rh-common-rpms enabled: 231 rhel-7-server-rpms rhel-7-server-rpms enabled: 18,263 repolist: 19,320
So now I can start using this repository offline.
How to enable SSH access & configure network in rescue mode (CentOS/RHEL 7/8)
Lastly I hope the steps from the article to download entire repository from CentOS /RHEL 7 to your local Linux node was helpful. So, let me know your suggestions and feedback using the comment section.

被折叠的 条评论
为什么被折叠?



