In the latest release of Red Hat Enterprise Linux (RHEL) 8, the legacy yum (Yellowdog Updater Modifier) has been replaced by Fedora package manager i.e. dnf (Dandified yum). Although, yum command is still available for backward compatibility, but it is actually an alias that is redirecting to dnf command.
As you aware that, Red Hat Enterprise Linux (RHEL) 8 is a commercial software and we need a paid subscription to access online yum repositories to install software packages.
However, we can also configure a local yum repository of our own. So, we can conveniently install software packages on our RHEL 8 system without having a paid subscription.
In this article, we are configuring a Local yum Repository on Red hat Enterprise Linux (RHEL) 8 server.
Environment Specification:
We have configured a Red hat Enterprise Linux (RHEL) 8 virtual machine with following specifications.
- CPU – 3.4 Ghz (2 cores)
- Memory – 2 GB
- Storage – 20 GB
- Hostname – rhel-8-server.example.com
- IP Address – 192.168.116.165/24
- Operating System – Red hat Enterprise Linux (RHEL) 8
Configuring Local Yum Repository on RHEL 8:
Copy RHEL 8 ISO file to our rhel-8-server.example.com.
# ls
anaconda-ks.cfg rhel-8.0-x86_64-dvd.iso
Create a directory to mount rhel-8.0-x86_64-dvd.iso file.
# mkdir /mnt/iso
Persistently mount rhel-8.0-x86_64-dvd.iso at /mnt/iso directory.
# echo "/root/rhel-8.0-x86_64-dvd.iso /mnt/iso iso9660 defaults 0 0" >> /etc/fstab
# mount -a
mount: /mnt/iso: WARNING: device write-protected, mounted read-only.
In RHEL 8, the yum repository has been divided into two parts.
- BaseOS – It provides the parts of the distribution that give you a running userspace on physical hardware, a virtual machine, a cloud instance or a container.
- AppStream – It provides all the applications you might want to run in a given userspace.
Add BaseOS section for our local yum repository.
# cat > /etc/yum.repos.d/localyum.repo << EOF
> [localyum_BaseOS]
> name=localyum_BaseOS
> baseurl=file:///mnt/iso/BaseOS
> enabled=1
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
> EOF
Add AppStream section for our local yum repository.
# cat >> /etc/yum.repos.d/localyum.repo << EOF
> [localyum_AppStream]
> name=localyum_AppStream
> baseurl=file:///mnt/iso/AppStream
> enabled=1
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
> EOF
Build cache for our local yum repository.
# dnf makecache
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
localyum_AppStream 13 MB/s | 5.3 MB 00:00
localyum_BaseOS 13 MB/s | 2.2 MB 00:00
Metadata cache created.
Install Apache HTTP Server using dnf command.
# dnf install -y httpd
Our local yum repository is working fine. Now, we are going to share the same local yum repository to our network RHEL 8 clients.
For this purpose, we required Apache HTTP server (that we have installed already) and a couple of amendments in configurations of our local yum repository.
Put SELinux in permissive mode, so we can mount the ISO file in /var/www/html and the same can be accessible by the network clients.
# sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/sysconfig/selinux
# setenforce permissive
Enable and start Apache HTTP Service.
# systemctl enable httpd.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service /usr/lib/systemd/system/httpd.service.
# systemctl start httpd.service
Allow HTTP service in Linux firewall.
# firewall-cmd --permanent --add-service=http
success
# firewall-cmd --reload
success
Create a directory in /var/www/html to mount RHEL 8 ISO.
# mkdir /var/www/html/rhel8
Edit /etc/fstab file to change the mount point of /dev/cdrom.
/root/rhel-8.0-x86_64-dvd.iso /var/www/html/rhel8 iso9660 defaults 0 0
Remount the ISO file.
# mount -a
mount: /var/www/html/rhel8: WARNING: device write-protected, mounted read-only.
Edit localyum.repo file and update baseurls as follows.
[localyum_BaseOS]
name=localyum_BaseOS
baseurl=http://192.168.116.165/rhel8/BaseOS
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[localyum_AppStream]
name=localyum_AppStream
baseurl=http://192.168.116.165/rhel8/AppStream
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Rebuild yum cache.
# dnf clean all
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
12 files removed
# dnf makecache
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
localyum_AppStream 24 MB/s | 5.3 MB 00:00
localyum_BaseOS 76 MB/s | 2.2 MB 00:00
Metadata cache created.
Check list of repositories on our RHEL 8 server.
# dnf repolist
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:22:17 ago on Fri 05 Jul 2019 12:51:12 AM PKT.
repo id repo name status
localyum_AppStream localyum_AppStream 4,672
localyum_BaseOS localyum_BaseOS 1,658
We have successfully configured Local yum repository on Red Hat Enterprise Linux (RHEL) 8.