RHCSA Practical Lab Series β Configuring YUM/DNF Repositories
π Lab 2: Setting Up Your System to Use Default Repositories
π Objective
Configure your system to use local repositories by creating a custom YUM/DNF repo file. You will:
β Manually define a repository for BaseOS and AppStream
β Verify repository settings
β Install a package using the new repository
π Step 1: Create a Custom YUM Repository File
Red Hat uses YUM/DNF package managers to install software. Instead of relying on external repositories, we'll configure local repositories using an internal server.
1οΈβ£ Open the YUM repository configuration file
[root@node1 ~]# vim /etc/yum.repos.d/rhcsa.repo
π This command opens the file in Vim editor. If Vim is not installed, use nano
instead:
[root@node1 ~]# nano /etc/yum.repos.d/rhcsa.repo
π Step 2: Define BaseOS and AppStream Repositories
Inside the rhcsa.repo
file, add the following configuration:
[Base]
name=Base
baseurl=http://content/rhel9.0/x86_64/dvd/BaseOS
enabled=1
gpgcheck=no
[App]
name=App
baseurl=http://content/rhel9.0/x86_64/dvd/AppStream
enabled=1
gpgcheck=no
πΉ Explanation of the configuration:
[Base]
β Defines a repository named Base for essential system packages.name=Base
β Display name for the repository.baseurl=http://content/rhel9.0/x86_64/dvd/BaseOS
β URL for fetching packages.enabled=1
β Enables this repository.gpgcheck=no
β Disables signature verification (not recommended for production systems).[App]
β Defines a repository named App for application packages.
π Tip:
- Ensure the base URL is accessible (
ping content
can check connectivity). - If working with a local ISO/DVD repository, mount it first:
[root@node1 ~]# mount -o loop /dev/cdrom /mnt
And modify the baseurl
accordingly:
baseurl=file:///mnt/BaseOS
baseurl=file:///mnt/AppStream
π Step 3: Verify Repository Configuration
After saving the file, verify that the repositories are correctly set up:
[root@node1 ~]# yum repoinfo
πΉ Expected Output (partial):
Repo-id : Base
Repo-name : Base
Repo-revision: 123456789
Repo-baseurl : http://content/rhel9.0/x86_64/dvd/BaseOS
Repo-expire : 172800 second(s) (last: Thu Mar 28 12:45:56 2024)
Repo-filename: /etc/yum.repos.d/rhcsa.repo
Repo-id : App
Repo-name : App
Repo-revision: 987654321
Repo-baseurl : http://content/rhel9.0/x86_64/dvd/AppStream
Repo-expire : 172800 second(s) (last: Thu Mar 28 12:45:56 2024)
Repo-filename: /etc/yum.repos.d/rhcsa.repo
β If the repositories are listed, the configuration is correct.
π Troubleshooting:
- If the repository doesnβt appear, check for typos in
/etc/yum.repos.d/rhcsa.repo
. - If using a local DVD, ensure it is mounted (
df -h
can check).
π Step 4: Install a Test Package
Now, install a package (vsftpd
) to verify that YUM/DNF is working:
[root@node1 ~]# yum -y install vsftpd
πΉ Expected Output (partial):
Installing : vsftpd-3.0.3-34.el9.x86_64 1/1
Verifying : vsftpd-3.0.3-34.el9.x86_64 1/1
Installed:
vsftpd-3.0.3-34.el9.x86_64
Complete!
β If the installation completes successfully, your repository is working.
π Step 5: Verify Installed Package
To check if the package is correctly installed:
[root@node1 ~]# rpm -q vsftpd
πΉ Expected Output:
vsftpd-3.0.3-34.el9.x86_64
β This confirms the package was installed from the configured repository.
π Step 6: Enable and Start the Service (Optional)
If using vsftpd
for FTP services, start and enable it:
[root@node1 ~]# systemctl enable --now vsftpd
πΉ Verify service status:
[root@node1 ~]# systemctl status vsftpd
πΉ Expected Output (partial):
β vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2024-03-28 13:00:00 UTC; 2min ago
β Your FTP server is now running!
π Step 7: Ensure Repository Persists After Reboot
Reboot the system:
[root@node1 ~]# reboot
After reboot, verify the repository and package installation:
[root@node1 ~]# yum repoinfo
[root@node1 ~]# rpm -q vsftpd
πΉ Expected Output:
vsftpd-3.0.3-34.el9.x86_64
β If the repo and package persist, everything is correctly configured.
β Final Summary
In this lab, you successfully:
β Created a custom YUM repository configuration
β Verified repository settings
β Installed vsftpd using the configured repo
β Ensured persistent configuration
π Next Lab: Configuring Firewalld to Allow HTTP on Port 8080
π© Subscribe for more RHCSA exam labs and hands-on tutorials! π