Site icon UnixArena

How to Merge/Update Redhat Linux YUM Repositories ?

YUM repository update - RHEL 7

YUM repository update - RHEL 7

Redhat Linux YUM  repository is useful for installing packages , updating the packages and upgrade the operating system with automatic  dependency selection method. In larger environment , we need to setup the repository via HTTP to make the YUM  repository to be available over network. At the same time , you might have different RHEL versions  might be running on the environment. So how to maintain a single YUM repository across the environment ?  This can be done by setting up yum repositories over http and merging RHEL ISO repositories.

 

Prerequisites: 

 

1. Login to your YUM repository server. In this server RHEL7 repository is already configured.

[root@uaans ~]# yum repolist
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id                                                                repo name                                                               status
!uaans-repo                                                            UAANS-GLOBAL                                                            4,305
repolist: 4,305
[root@uaans ~]#

2. Install required packages for repo update.

[root@uaans repo]# yum install createrepo yum-utils
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package yum-utils-1.1.31-24.el7.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package createrepo.noarch 0:0.9.9-23.el7 will be installed
--> Processing Dependency: deltarpm for package: createrepo-0.9.9-23.el7.noarch
--> Processing Dependency: python-deltarpm for package: createrepo-0.9.9-23.el7.noarch
--> Running transaction check
---> Package deltarpm.x86_64 0:3.6-3.el7 will be installed
---> Package python-deltarpm.x86_64 0:3.6-3.el7 will be installed
--> Finished Dependency Resolution

3. Mount RHEL 7.5 DVD under /mnt/.

[root@uaans ~]# mount /dev/sr1 /mnt
mount: /dev/sr1 is write-protected, mounting read-only
[root@uaans ~]# cd /mnt
[root@uaans mnt]# ls -lrt
total 952
-r--r--r--. 1 root root  18092 Mar  6  2012 GPL
-r--r--r--. 1 root root   8266 Apr  4  2014 EULA
-r--r--r--. 1 root root   3211 Feb 28 10:42 RPM-GPG-KEY-redhat-release
-r--r--r--. 1 root root   3375 Feb 28 10:42 RPM-GPG-KEY-redhat-beta
-r--r--r--. 1 root root   1455 Mar 22 11:55 extra_files.json
-r--r--r--. 1 root root    114 Mar 22 12:01 media.repo
-r--r--r--. 1 root root   1796 Mar 22 12:04 TRANS.TBL
dr-xr-xr-x. 2 root root   4096 Mar 22 12:04 repodata
dr-xr-xr-x. 2 root root 921600 Mar 22 12:04 Packages
dr-xr-xr-x. 2 root root   2048 Mar 22 12:04 LiveOS
dr-xr-xr-x. 2 root root   2048 Mar 22 12:04 isolinux
dr-xr-xr-x. 3 root root   2048 Mar 22 12:04 images
dr-xr-xr-x. 3 root root   2048 Mar 22 12:04 EFI
dr-xr-xr-x. 4 root root   2048 Mar 22 12:04 addons
[root@uaans mnt]#

4. Find the below information using yum-config-manager command. You could also check these configurations in /etc/yum.repos.d/uaans.repo file. (Find out your repo file )

[root@uaans ~]# yum-config-manager  |egrep "baseurl|ui_id"
baseurl = file:///var/repo
ui_id = uaans-repo
[root@uaans ~]#

5. Ensure /var/repo (where the current repositories resides) have sufficient space to accommodate RHEL 7.5 repo.

 

6. From /mnt , copy media.repo file to /etc/yum.repos.d directory and add baseurl.

[root@uaans mnt]# cp media.repo /etc/yum.repos.d/
[root@uaans yum.repos.d]# cd /etc/yum.repos.d/
[root@uaans yum.repos.d]# echo "baseurl=file:///mnt" >> media.repo
[root@uaans yum.repos.d]# cat media.repo
[InstallMedia]
name=Red Hat Enterprise Linux 7.5
mediaid=1521745267.626363
metadata_expire=-1
gpgcheck=0
cost=500
baseurl=file:///mnt
[root@uaans yum.repos.d]#

 

7. List the available repository.

[root@uaans yum.repos.d]# yum repolist
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id                                                        repo name                                                                       status
InstallMedia                                                   Red Hat Enterprise Linux 7.5                                                    5,099
uaans-repo                                                     UAANS-GLOBAL                                                                    4,305
repolist: 9,404
[root@uaans yum.repos.d]#

8. Let’s merge/update “uaans-repo” repository from InstallMedia.

[root@uaans yum.repos.d]# reposync -p /var/repo/Packages/ --repoid=InstallMedia --norepopath -l -u |head
Loaded plugins: langpacks, product-id
file:///mnt/Packages/389-ds-base-1.3.7.5-18.el7.x86_64.rpm
file:///mnt/Packages/389-ds-base-libs-1.3.7.5-18.el7.x86_64.rpm
file:///mnt/Packages/ElectricFence-2.2.2-39.el7.i686.rpm
file:///mnt/Packages/ElectricFence-2.2.2-39.el7.x86_64.rpm
file:///mnt/Packages/GConf2-3.2.6-8.el7.i686.rpm
file:///mnt/Packages/GConf2-3.2.6-8.el7.x86_64.rpm
file:///mnt/Packages/GeoIP-1.5.0-11.el7.i686.rpm
file:///mnt/Packages/GeoIP-1.5.0-11.el7.x86_64.rpm
file:///mnt/Packages/ImageMagick-6.7.8.9-15.el7_2.i686.rpm
[root@uaans yum.repos.d]# reposync -p /var/repo --repoid=InstallMedia --norepopath -l -u |wc -l
5100
[root@uaans yum.repos.d]#

* -u option won’t download the package to the destination directory . It just lists the files going to be synced or copied in existing repository.
* Almost 5100 rpm packages will be synced/copied during this activity.
* -p =- Destination repository directory.
* -norepopath Don’t add the reponame to the download path. Can only be used when syncing a single repository
(default is to add the reponame)
* -n, –newest-only Download only newest packages per-repo
* -l, –plugins enable yum plugin support

 

If you would like to maintain 7.0 & 7.5 packages in different directory , just remove “norepopath” .

Let’s begin to  update the repo.

[root@uaans yum.repos.d]# reposync -p /var/repo --repoid=InstallMedia -l
Loaded plugins: langpacks, product-id
(1/5099): 389-ds-base-libs-1.3.7.5-18.el7.x86_64.rpm                       | 695 kB  00:00:00
(2/5099): 389-ds-base-1.3.7.5-18.el7.x86_64.rpm                            | 1.7 MB  00:00:00
(3/5099): ElectricFence-2.2.2-39.el7.i686.rpm                              |  35 kB  00:00:00
(4/5099): ElectricFence-2.2.2-39.el7.x86_64.rpm                            |  35 kB  00:00:00
(5/5099): GConf2-3.2.6-8.el7.i686.rpm                                      | 1.0 MB  00:00:00
(6/5099): GeoIP-1.5.0-11.el7.i686.rpm                                      | 1.1 MB  00:00:00
(7/5099): GConf2-3.2.6-8.el7.x86_64.rpm                                    | 1.0 MB  00:00:00
(8/5099): ImageMagick-6.7.8.9-15.el7_2.i686.rpm                            | 2.1 MB  00:00:00
(9/5099): GeoIP-1.5.0-11.el7.x86_64.rpm                                    | 1.1 MB  00:00:00
(10/5099): ImageMagick-c++-6.7.8.9-15.el7_2.i686.rpm                       | 152 kB  00:00:00
(11/5099): ImageMagick-c++-6.7.8.9-15.el7_2.x86_64.rpm                     | 146 kB  00:00:00
(12/5099): ImageMagick-perl-6.7.8.9-15.el7_2.x86_64.rpm                    | 147 kB  00:00:00
(13/5099): ImageMagick-6.7.8.9-15.el7_2.x86_64.rpm                         | 2.1 MB  00:00:00
(14/5099): LibRaw-0.14.8-5.el7.20120830git98d925.x86_64.rpm                | 250 kB  00:00:00
(15/5099): LibRaw-0.14.8-5.el7.20120830git98d925.i686.rpm                  | 245 kB  00:00:00
(16/5099): ModemManager-1.6.10-1.el7.x86_64.rpm                            | 737 kB  00:00:00
(17/5099): ModemManager-glib-1.6.10-1.el7.x86_64.rpm                       | 231 kB  00:00:00
(18/5099): MySQL-python-1.2.5-1.el7.x86_64.rpm                             |  90 kB  00:00:00
(19/5099): ModemManager-glib-1.6.10-1.el7.i686.rpm                         | 229 kB  00:00:00
(20/5099): NetworkManager-1.10.2-13.el7.x86_64.rpm                         | 1.7 MB  00:00:00
(21/5099): NetworkManager-adsl-1.10.2-13.el7.x86_64.rpm                    | 158 kB  00:00:00
(22/5099): NetworkManager-config-server-1.10.2-13.el7.noarch.rpm           | 143 kB  00:00:00

All the 5099 packages must be copied to the existing local repository.

 

9. Move the newly created repository directory in to meaningful name. Navigate to the repository directory /var/repo.

[root@uaans yum.repos.d]# cd /var/repo
[root@uaans repo]# ls -lrt
total 688
-r--r--r--.  1 root root  18092 Mar  6  2012 GPL
-r--r--r--.  1 root root   3211 Apr  1  2014 RPM-GPG-KEY-redhat-release
-r--r--r--.  1 root root   3375 Apr  1  2014 RPM-GPG-KEY-redhat-beta
-r--r--r--.  1 root root   8266 Apr  4  2014 EULA
-r--r--r--.  1 root root    108 May  7  2014 media.repo
-r--r--r--.  1 root root   1568 May  7  2014 TRANS.TBL
dr-xr-xr-x.  2 root root   4096 May  7  2014 repodata
dr-xr-xr-x. 24 root root   4096 May  7  2014 release-notes
dr-xr-xr-x.  2 root root 229376 May  7  2014 Packages
dr-xr-xr-x.  2 root root     41 May  7  2014 LiveOS
dr-xr-xr-x.  2 root root   4096 May  7  2014 isolinux
dr-xr-xr-x.  3 root root     54 May  7  2014 images
dr-xr-xr-x.  3 root root     17 May  7  2014 EFI
dr-xr-xr-x.  4 root root     52 May  7  2014 addons
drwxr-xr-x.  2 root root 266240 May  5 10:28 InstallMedia
[root@uaans repo]# mv InstallMedia Packages-RHEL7.5
[root@uaans repo]# ls -ld Packages-RHEL7.5
drwxr-xr-x. 2 root root 266240 May  5 10:28 Packages-RHEL7.5
[root@uaans repo]#

10. Update the repository  to build the package database.

[root@uaans repo]# createrepo --update /var/repo
Spawning worker 0 with 5156 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@uaans repo]#

11. Repository has been updated with RHEL 7.5. The current repository holds both 7.0 & 7.5 packages. It’s time to test . Just run a yum update where the current system just runs on RHEL 7.0.

[root@uaans repo]# yum update
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package ModemManager-glib.x86_64 0:1.1.0-6.git20130913.el7 will be updated
---> Package ModemManager-glib.x86_64 0:1.6.10-1.el7 will be an update
---> Package NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 will be obsoleted
---> Package NetworkManager.x86_64 1:1.10.2-13.el7 will be obsoleting

We could see that packages are available to update the system to RHEL 7.5.

 

In this system repository is configured locally . Here is the step by step guide to convert the existing repository to make it available in network via HTTP.

 

If the clients already using the repository , cache must be removed to see the updated repository.

# rm -rf /var/cache/yum/*
# yum clean all

 

Hope this article is informative to you . Share it ! Comment it !! Be sociable .!!!

Exit mobile version