In this post, I describes how to setup a local Yum repository on CentOS 7 & RHEL 7 server operating system.
The local YUM repository is the most significant way to perform any type of package installation without any internet connection. If you have to install software, security updates and fixes often in multiple systems in your local network, then having a local repository is an efficient way.
All required packages are downloaded over the fast LAN connection from your local server, so that it will save your Internet bandwidth and reduces your annual cost of Internet.
Now, please find the step by step method to create a YUM repository on RHEL 7 & CentOS 7.
Mount the Local Media:
In this step we mount our CentOS 7 / RHEL 7 installation DVD. For example, let us mount the installation media on /mnt directory.
#mount -o loop /dev/cdrom /mnt
In my Linux machine i will insert the ISO on cdrom and mount it on /mnt directory.
Copy or Extract the Media:
In this step, we will extract or copy iso files to local machine. For this work we will create a one mount point directory and copy all the packages files from /mnt.
#mkdir /centos
#cp -rvf /mnt/* /centos
So all the packages are copied on the "/centos" directory.
Install repository packages:
In this step, we will create repository but before this we need to install the "createrepo" rpm on the YUM server.
For createrepo, you need to install some dependency rpm which are listed in "Packages" folder.
#rpm -ivh libxml2-python-2.9.1-5.el7_0.1.x86_64.rpm
#rpm -ivh python-deltarpm-3.6-3.el7.x86_64.rpm
#rpm -ivh deltarpm-3.6-3.el7.x86_64.rpm
#rpm -ivh createrepo-0.9.9-23.el7.noarch.rpm
Once these required packages is installed we create the repo using createrepo command.
#createrepo -v /centos/Packages
Remove the Online Repository:
Please remove the old repository from /etc/yum.repos.d directory. In this directory all the default local centOS / RHEL repository are exist.
#rm -rf /etc/yum.repos.d/*
Create Local Repository:
In this step we will create the local repostiory which is always kept as a local. Using this local repo we can install all the packages and their dependency.
#vi /etc/yum.repos.d/local.repo
[Packages]
baseurl=file:///centos/Packages
gpgcheck=0
enable=1
After save the file your local.repo repository has been created. In next step we will enable it.
Enable Local Repository:
After successfully creation of YUM repository we will enable it.
#yum clean all
#yum repolist all
Using this repolist command you can check the newly created and existing repository on the server. After that you can easily install the pacakges using YUM in RHEL 7 & CentOS 7.