CentOS / Red Hat Local Repository

If you have many Linux machines that needs to updated or install some packages they would use Internet connection to get required data, but as many as you have machines it will consume more bandwidth and money , So it is recommended to have Local Repository to serve all other machines , we will do it for centOS/RedHat but the concept is the same for other distributions , Let’s go..

01. Configure Server:

To create Local repository server we need Packages from ISO images or directly from Web Site for your mirror, we may use DVD iso or EveryThing iso from CentOS Isos , and we need File server to host this packages publicly like FTP , and to create repo files we use createrepo command.

 yum -y install vsftpd createrepo
 systemctl start vsftpd
 systemctl enable vsftpd

 firewall-cmd --permanent --add-service=ftp
 firewall-cmd --reload

If you burned your iso to disk and use it, mount it looks like that:

mount /dev/sr0 /mnt

OR if you have iso image file locally , mount looks like that:

mount CentOS-7-x86_64-Everything-1611.iso /mnt

Copy Packages to a directory in vsftp from Packages folder in the mount point:

 mkdir /var/ftp/pub/centos
 cp -v /mnt/Packages/*.* /var/ftp/pub/centos7/

Now we ready to make a repository on our packages path:

createrepo -v /var/ftp/pub/centos7/

If you added or removed any packages from repository make sure to update repo database bu issuing that command against our Packages directory:

createrepo --update /var/ftp/pub/centos7
02. Configure clients:

the best easy way to add repository to clients is to create a new file with .repo extension in /etc/yum.repo.d/

Example: say that server IP that vsftp listen on is  , on client the repo file looks like that:

 name= REPO Name
 # you may point to repo directory path on server itself

*Change repo ID or name as you like but keep it meaningful

gpgcheck=0 because we don’t have signature key, not so important locally , but always used with public repositories

*you may copy that file to all clients to use our repo

03. Test :

on client check if repo is listed:

yum repolist

Congratulations , now you can update and install packages faster and lower bandwidth because it is all locally.

Enjoy !.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s