Author Photo

Ahmer's SysAdmin Recipes is a blog for Linux System Administrators. This blog provides recipes for Installation & Configuration of Linux, Ubuntu, Oracle Database, MySQL, Apache, Nginx, Oracle Cloud Control, FreeIPA, Kerberos & OpenLDAP, Subversion, PXE, DevOps, etc. over Red Hat Enterprise Linux (RHEL), CentOS, Ubuntu and Windows.

Please give me your feedback and help me improve this blog. Please let me know If you want me to write on a specific topic.

Saturday, 6 July 2019

Configure Local YUM/DNF repository in RHEL 8

Configure Local YUM/DNF repository in RHEL 8In 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/DNF repositories to install software packages.

However, we can also configure a local YUM/DNF 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/DNF 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/DNF Repository on RHEL 8:

Copy RHEL 8 ISO file to our rhel-8-server.example.com.

[root@rhel-8-server ~]# ls anaconda-ks.cfg rhel-8.0-x86_64-dvd.iso

Create a directory to mount rhel-8.0-x86_64-dvd.iso file.

[root@rhel-8-server ~]# mkdir /mnt/iso

Persistently mount rhel-8.0-x86_64-dvd.iso at /mnt/iso directory.

[root@rhel-8-server ~]# echo "/root/rhel-8.0-x86_64-dvd.iso /mnt/iso iso9660 defaults 0 0" >> /etc/fstab [root@rhel-8-server ~]# mount -a mount: /mnt/iso: WARNING: device write-protected, mounted read-only.

In RHEL 8, the yum repository has been divided into two parts.

  1. 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.
  2. AppStream – It provides all the applications you might want to run in a given userspace.

Add BaseOS section for our local yum repository.

[root@rhel-8-server ~]# 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.

[root@rhel-8-server ~]# 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.

[root@rhel-8-server ~]# 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.

[root@rhel-8-server ~]# dnf install -y httpd 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:01:13 ago on Fri 05 Jul 2019 12:02:54 AM PKT. Dependencies resolved. ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: httpd x86_64 2.4.37-10.module+el8+2764+7127e69e localyum_AppStream 1.4 M Installing dependencies: apr x86_64 1.6.3-9.el8 localyum_AppStream 125 k apr-util x86_64 1.6.1-6.el8 localyum_AppStream 105 k httpd-filesystem noarch 2.4.37-10.module+el8+2764+7127e69e localyum_AppStream 34 k httpd-tools x86_64 2.4.37-10.module+el8+2764+7127e69e localyum_AppStream 101 k mod_http2 x86_64 1.11.3-1.module+el8+2443+605475b7 localyum_AppStream 156 k mailcap noarch 2.1.48-3.el8 localyum_BaseOS 39 k redhat-logos-httpd noarch 80.7-1.el8 localyum_BaseOS 25 k Installing weak dependencies: apr-util-bdb x86_64 1.6.1-6.el8 localyum_AppStream 25 k apr-util-openssl x86_64 1.6.1-6.el8 localyum_AppStream 27 k Enabling module streams: httpd 2.4 Transaction Summary ================================================================================ Install 10 Packages Total size: 2.0 M Installed size: 5.5 M Downloading Packages: warning: /mnt/iso/AppStream/Packages/apr-1.6.3-9.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY localyum_AppStream 514 kB/s | 5.0 kB 00:00 Importing GPG key 0xFD431D51: Userid : "Red Hat, Inc. (release key 2) <security@redhat.com>" Fingerprint: 567E 347A D004 4ADE 55BA 8A5F 199E 2F91 FD43 1D51 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release Key imported successfully Importing GPG key 0xD4082792: Userid : "Red Hat, Inc. (auxiliary key) <security@redhat.com>" Fingerprint: 6A6A A7C9 7C88 90AE C6AE BFE2 F76F 66C3 D408 2792 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : apr-1.6.3-9.el8.x86_64 1/10 Running scriptlet: apr-1.6.3-9.el8.x86_64 1/10 Installing : apr-util-bdb-1.6.1-6.el8.x86_64 2/10 Installing : apr-util-openssl-1.6.1-6.el8.x86_64 3/10 Installing : apr-util-1.6.1-6.el8.x86_64 4/10 Running scriptlet: apr-util-1.6.1-6.el8.x86_64 4/10 Installing : httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86 5/10 Installing : redhat-logos-httpd-80.7-1.el8.noarch 6/10 Installing : mailcap-2.1.48-3.el8.noarch 7/10 Running scriptlet: httpd-filesystem-2.4.37-10.module+el8+2764+7127e69 8/10 Installing : httpd-filesystem-2.4.37-10.module+el8+2764+7127e69 8/10 Installing : mod_http2-1.11.3-1.module+el8+2443+605475b7.x86_64 9/10 Installing : httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64 10/10 Running scriptlet: httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64 10/10 Verifying : apr-1.6.3-9.el8.x86_64 1/10 Verifying : apr-util-1.6.1-6.el8.x86_64 2/10 Verifying : apr-util-bdb-1.6.1-6.el8.x86_64 3/10 Verifying : apr-util-openssl-1.6.1-6.el8.x86_64 4/10 Verifying : httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64 5/10 Verifying : httpd-filesystem-2.4.37-10.module+el8+2764+7127e69 6/10 Verifying : httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86 7/10 Verifying : mod_http2-1.11.3-1.module+el8+2443+605475b7.x86_64 8/10 Verifying : mailcap-2.1.48-3.el8.noarch 9/10 Verifying : redhat-logos-httpd-80.7-1.el8.noarch 10/10 Installed products updated. Installed: httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64 apr-util-bdb-1.6.1-6.el8.x86_64 apr-util-openssl-1.6.1-6.el8.x86_64 apr-1.6.3-9.el8.x86_64 apr-util-1.6.1-6.el8.x86_64 httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86_64 mod_http2-1.11.3-1.module+el8+2443+605475b7.x86_64 mailcap-2.1.48-3.el8.noarch redhat-logos-httpd-80.7-1.el8.noarch Complete!

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.

[root@rhel-8-server ~]# sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/sysconfig/selinux [root@rhel-8-server ~]# setenforce permissive

Enable and start Apache HTTP Service.

[root@rhel-8-server ~]# systemctl enable httpd.service Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service รข /usr/lib/systemd/system/httpd.service. [root@rhel-8-server ~]# systemctl start httpd.service

Allow HTTP service in Linux firewall.

[root@rhel-8-server ~]# firewall-cmd --permanent --add-service=http success [root@rhel-8-server ~]# firewall-cmd --reload success

Create a directory in /var/www/html to mount RHEL 8 ISO.

[root@rhel-8-server ~]# 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.

[root@rhel-8-server ~]# 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/DNF cache.

[root@rhel-8-server ~]# 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 [root@rhel-8-server ~]# 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.

[root@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/DNF repository on Red Hat Enterprise Linux (RHEL) 8.

Configure Local YUM/DNF repository in RHEL 8


YOU MIGHT ALSO LIKE:

No comments:

Post a Comment