How to Configure Local YUM Repository Package Manager on RHEL 7/CentOS 7

In this article, we are going to discuss how to configure local Yum Repository Package Manager on RHEL 7/CentOS 7. Yum stands for Yellowpage Updater Supplier Modifier for RPM Package Supported Linux Distro/Operating System ex: RHEL 5/6/7 and so on. It is used to search, update, list available packages, list installed packages and RPM packages from the database. The main objective of Yum is to establish RPM packages with the necessary dependencies and package management in a convenient manner for administrators. YUM was first introduced on RHEL 5 and was available on all later versions. By default, You can use Yum to install packages by downloading from the Internet, but you can configure local Yum repository package manager server by using the RHEL installation DVD or by placing packages on remote servers such as FTP, HTTP. In this article, we want to learn how to configure the local YUM repository package manager using FTP server ie vsftpd server.

How to Configure Local YUM Repository Package Manager on RHEL 7/CentOS 7

How to Configure Local YUM Repository Package Manager on RHEL 7/CentOS 7

So let’s take a look at the installation and configuration steps of the local YUM repository package manager.

My Scenario for YUM Repository:
Server Side :
IP Address – 192.168.1.100
OS – RHEL 7

Client Side :
IP Address: 192.168.1.101
OS – RHEL 6.8

Follow the below steps to Configure Local YUM Repository Package Manager on RHEL 7/CentOS 7:

Step: 1 Install Required Packages:

First, you will need to install all the packages you need to configure the Yum Repository Package Manager. For this, the following packages must be installed:

yum.xxx.xxx.xx.rpm
yum-utils.xxx.xxx.xx.rpm
createrepo.xxx.xxx.xx.rpm
vsftpd.xxx.xxx.xx.rpm

You will find all packages from the RHEL installation media, so mount the installation DVD and install all the packages using the following command.

[root@localhost packages]# rpm -ivh yum-3.2.29-73.el6.centos.noarch.rpm 
Preparing...                ########################################### [100%]
   1:yum                    ########################################### [100%]
[root@localhost packages]# rpm -ivh yum-utils-1.1.30-37.el6.noarch.rpm 
Preparing...                ########################################### [100%]
   1:yum-utils              ########################################### [100%]
[root@localhost packages]# rpm -ivh vsftpd-2.2.2-21.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:vsftpd                 ########################################### [100%]
[root@localhost pub]# rpm -ivh createrepo-0.9.9-24.el6.noarch.rpm 
Preparing...                ########################################### [100%]
   1:createrepo             ########################################### [100%]

You can confirm package installation using the following commands.

[root@localhost ~]# rpm -qa | grep yum
yum-3.2.29-73.el6.centos.noarch
yum-utils-1.1.30-37.el6.noarch

[root@localhost ~]# rpm -qa | grep vsftpd
vsftpd-2.2.2-21.el6.x86_64

Step: 2 Configure the Vsftpd Server:

We are going to configure the local yum repository package manager with the FTP server, that is, the Vsftps server, so we have to prepare the Vsftpf server before configuring YUM. For that, edit the main configuration file of the vsftpd server (/etc/vsftpd.conf) and search the below line and comment by removing #.

anonymous_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
idle_session_timeout=600
data_connection_timeout=120

After configuring the vsftpd server, mount the installation media and copy all the rpm packages into the vsftpd default directory, such as/var/ftp/pub.

[root@localhost Packages]# mount /dev/cdrom /media   
[root@localhost Packages]#cd /media/CentOS-6.8-x86_64-bin-DVD1/Packages   
[root@localhost Packages]# cp * -rfv /var/ftp/pub/

Start the Vsftpd server using the below command.

[root@localhost ~]# /etc/init.d/vsftpd start
Starting vsftpd for vsftpd:                                [  OK  ]

Step: 3 Configure YUM Repository from Server Side:

The main configuration file of the Yum repository is yum.conf, which is located in the / etc directory, namely /etc/yum.conf. Here we can see that our .repo files should be placed in the /etc/yum.repos.d directory.

Note: The .repo file is a repository of the YUM repository where we need to specify the path of the rpm package location. Here we have configured vsftpd server to hold rpm packages.

[root@localhost ~]# cat /etc/yum.conf  # See the yum.conf file just for Reference

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=19&ref=http://bugs.centos.org/bug_report_page.php?category=y$
distroverpkg=centos-release

#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

Now go to the /etc/yum.repos.d directory, where you can find some default .repo files. So here we have to move all the default .repo files to another directory and create a new .repo file using the touch command.

[root@localhost ~]# cd /etc/yum.repos.d/   
[root@localhost yum.repos.d]# ls
CentOS-Base.repo       CentOS-fasttrack.repo  CentOS-Vault.repo    CentOS-Debuginfo.repo  CentOS-Media.repo

# Here I created a Directory to move Sample .repo Files

[root@localhost yum.repos.d]# mkdir /data    
[root@localhost yum.repos.d]# mv CentOS* /data/
[root@localhost yum.repos.d]# touch file.repo

Now edit the file. repo YUM repository file, copy all the lines in it and then save the file.

[root@localhost yum.repos.d]# nano file.repo

[base]
name=base
baseurl=ftp://192.168.1.100/pub/
enabled=1
gpgcheck=0

After configuring the .repo file create the database for yum using the createrepo command as shown below. It creates a .xml file, stores all the package information, and is available from that XML file when the user tries to install any package.

[root@localhost ~]# createrepo /var/ftp/pub/  
Spawning worker 0 with 3204 pkgs
Workers Finished
Gathering worker results

Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

Reboot the Vsftpd server using the command below.

[root@localhost pub]# /etc/init.d/vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

Now we are done with all the necessary configurations. Now run the command below to list all the packages available in the yum database.

[root@localhost ~]# yum list

Step: 4 Configure YUM Repository from Client Side:

Install Required Packages:

Packages We need to install the packages needed to connect to the YUM repository server for information. To install the following packages:

yum.xxx.xxx.xx.rpm
yum-utils.xxx.xxx.xx.rpm

[root@localhost packages]# rpm -ivh yum-3.2.29-73.el6.centos.noarch.rpm 
Preparing...                ########################################### [100%]
   1:yum                    ########################################### [100%]
[root@localhost packages]# rpm -ivh yum-utils-1.1.30-37.el6.noarch.rpm 
Preparing...                ########################################### [100%]
   1:yum-utils              ########################################### [100%]

Configure the .repo file:

Then go to the /etc/yum.repos.d directory and move the default sample files to a directory as you did in the server configuration (Step 3) and create a new .repo file. Follow the steps below.

[root@localhost ~]# cd /etc/yum.repos.d/  
[root@localhost yum.repos.d]# ls
CentOS-Base.repo       CentOS-fasttrack.repo  CentOS-Vault.repo   
CentOS-Debuginfo.repo  CentOS-Media.repo

# Here I created a Directory to move Sample .repo Files
[root@localhost yum.repos.d]# mkdir /data
[root@localhost yum.repos.d]# mv CentOS* /data/
[root@localhost yum.repos.d]# touch file.repo

After creating a .repo file, edit it and copy the lines below and save the file.

[root@localhost yum.repos.d]# nano file.repo

[base]
name=base
baseurl=ftp://192.168.1.100/pub/
enabled=1
gpgcheck=0

Now we’re done with the YUM repository client configuration. Use the yum command now to install a package for testing purposes. Follow the steps below.

[root@localhost ~]# yum -y install dhcp
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.1.1-51.P1.el6.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package     Arch          Version                            Repository   Size
================================================================================
Installing:
 dhcp        x86_64        12:4.1.1-51.P1.el6.centos          base        823 k

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 823 k
Installed size: 1.9 M
Downloading Packages:
dhcp-4.1.1-51.P1.el6.centos.x86_64.rpm                   | 823 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64                        1/1 
  Verifying  : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64                        1/1 

Installed:
  dhcp.x86_64 12:4.1.1-51.P1.el6.centos                                         

Complete!

Also Read – How to install Git Repository in Ubuntu

That’s all, In this article, we have explained how to Configure Local YUM Repository Package Manager on RHEL 7/CentOS 7. I hope you enjoy this article. If you like this article, then just share it. If you have any questions about this article, please comment

Share this:

Mangesh Dhulap

This is Mangesh Dhulap the Founder and Editor of IT SMART TRICKS have 6+ years of Industrial Experience. We expect from our visitors to like, share, and comment on our posts.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.