RHCSA Practical Lab Series – Configuring YUM/DNF Repositories

Expertise in Cloud, Networking & DevOps
Photo by Martin Shreder / Unsplash

πŸ” Lab 17: Setting Up Default Package Repositories in RHEL 9

πŸ“Œ Objective

In this lab, you will:

βœ” Configure YUM/DNF repositories for package management
βœ” Set up BaseOS and AppStream repositories
βœ” Verify repository functionality and install packages


πŸ“Œ Step 1: Copy the Repository Configuration File

πŸ”Ή Copy an existing repository configuration file to the correct location:

[root@node2 ~]# scp root@node1:/etc/yum.repos.d/rhcsa.repo /etc/yum.repos.d/

πŸ“Œ Explanation:

  • scp β†’ Securely transfers files between nodes.
  • /etc/yum.repos.d/ β†’ The directory where YUM/DNF stores repository configurations.

βœ… Check if the file was copied successfully:

[root@node2 ~]# ls /etc/yum.repos.d/

πŸ”Ή Expected Output:

rhcsa.repo  redhat.repo

βœ… If rhcsa.repo is listed, proceed to Step 2.


πŸ“Œ Step 2: Manually Configure Repository Files

πŸ”Ή Open the repository configuration file:

[root@node2 ~]# vim /etc/yum.repos.d/rhcsa.repo

πŸ”Ή Ensure the file contains the following content:

[Base]
name=Base
baseurl=http://content/rhel9.0/x86_64/dvd/BaseOS
enabled=1
gpgcheck=no

[AppStream]
name=AppStream
baseurl=http://content/rhel9.0/x86_64/dvd/AppStream
enabled=1
gpgcheck=no

πŸ“Œ Explanation:

  • [Base] β†’ Defines the BaseOS repository.
  • [AppStream] β†’ Defines the AppStream repository.
  • baseurl β†’ Points to the repository location.
  • enabled=1 β†’ Activates the repository.
  • gpgcheck=no β†’ Disables GPG key verification (for testing purposes).

βœ… Save and exit the file (ESC + :wq).


πŸ“Œ Step 3: Verify Repository Configuration

πŸ”Ή Confirm that the new repositories are recognized:

[root@node2 ~]# yum repoinfo

πŸ”Ή Expected Output:

Repo-id      : Base
Repo-name    : BaseOS
Repo-baseurl : http://content/rhel9.0/x86_64/dvd/BaseOS
Enabled      : Yes

Repo-id      : AppStream
Repo-name    : AppStream
Repo-baseurl : http://content/rhel9.0/x86_64/dvd/AppStream
Enabled      : Yes

βœ… If both repositories are listed, they are correctly configured.


πŸ“Œ Step 4: Install and Test a Package

πŸ”Ή Try installing an essential package (e.g., vsftpd for FTP server):

[root@node2 ~]# yum -y install vsftpd

πŸ“Œ Explanation:

  • -y β†’ Automatically confirms installation.
  • vsftpd β†’ The package name (from BaseOS/AppStream repositories).

βœ… Verify the installation:

[root@node2 ~]# rpm -q vsftpd

πŸ”Ή Expected Output:

vsftpd-3.0.3-44.el9.x86_64

βœ… If the package is installed successfully, the repository is fully functional.


πŸ“Œ Step 5: Enable and Start the Installed Service (Optional)

πŸ”Ή Enable and start the vsftpd service:

[root@node2 ~]# systemctl enable --now vsftpd

πŸ”Ή Check if the service is running:

[root@node2 ~]# systemctl status vsftpd

πŸ”Ή Expected Output:

● vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2024-03-25 11:00:00 UTC; 5s ago

βœ… If Active: running, the FTP server is running successfully.


πŸ“Œ Troubleshooting Tips

πŸ”Ή If the repository does not work, try clearing and updating the cache:

[root@node2 ~]# yum clean all
[root@node2 ~]# yum makecache

πŸ”Ή If the package installation fails, check for network connectivity:

[root@node2 ~]# ping -c 4 content

πŸ”Ή If the repository URL is incorrect, manually verify with curl:

[root@node2 ~]# curl -I http://content/rhel9.0/x86_64/dvd/BaseOS

βœ… If a 200 OK response is received, the URL is accessible.


βœ… Final Summary

βœ” Configured BaseOS and AppStream repositories
βœ” Verified repository functionality with yum repoinfo
βœ” Installed and tested vsftpd to confirm package management works
βœ” Enabled and started a service from the repository


πŸ“Œ Next Lab: Adjusting Logical Volume Size in RHEL 9

πŸ“© Subscribe for more RHCSA exam labs and hands-on tutorials! πŸš€


Read more