How to configure CentOS Local Yum Repository

Share on Social Media

In this tutorial, you will learn, how to configure CentOS Local Yum Repository. #centlinux #linux #yum

Problem Statement:

In RPM based Linux distros, sometimes it is getting very difficult to resolve dependencies especially if it exist in a chain manner. This is where the yum comes into play, but it requires a repository to connect and download the packages. If server has access to the Internet, then it is very easy to connect to public repositories on the Internet. However, private networks servers usually do not have access to the Internet. For such environment, we are required to setup a yum repository for easy and fast installation of packages.

Read Also: How to setup Local Yum Repository in CentOS 7

Configure Local Yum Repository in CentOS 6:

Login to the Server that you want to setup as the Local Yum Repository Server.

Mount the CDROM and copy packages folder from cdrom to a local folder /var/ftp/pub/yum_repo.

mkdir –p /work/cdrom
mount /dev/cdom /work/cdrom
mkdir –p /var/ftp/pub/yum_repo
cp /work/cdrom/Packages/* /var/ftp/pub/yum_repo
umount /dev/cdrom

Install create-repo package (including dependencies) from the yum_repo folder.

cd /var/ftp/pub/yum_repo
rpm –Uvh create-repo*
Local Yum Repo 1
Local Yum Repo 1

Go to the local yum folder and create repository.

cd /var/ftp/pub/yum_repo
createrepo .
Local Yum Repo 2
Local Yum Repo 2
Local Yum Repo 3
Local Yum Repo 3
Local Yum Repo 4
Local Yum Repo 4

Once the repository created successfully, add it to the server yum repo profile as /etc/yum.repos.d/rhel_local.repo.

vi /etc/yum.repos.d/rhel_local.repo
Local Yum Repo 5
Local Yum Repo 5

Test configuration by query the yum repolist.

Local Yum Repo 6
Local Yum Repo 6

At this point the Local yum repository is successfully configured for the local server. However, our objective is to make it accessible by all the servers on the network, therefore we required to setup FTP services on this server.

yum install vsftpd
chkconfig vsftpd on
service vsftp start

Set necessary configurations for vsftpd.

vi /etc/vsftpd/vsftpd.conf

and set following parameter.

Local Yum Repo 7
Local Yum Repo 7

Save the configuration file and restart the vsftpd service.

service vsftpd restart

Allow FTP port in Firewall.

system-config-firewall-tui
Local Yum Repo 8
Local Yum Repo 8

Select the service ftp and press space key to enable it.

Local Yum Repo 9
Local Yum Repo 9

Press Close to return to main screen.

Local Yum Repo 10
Local Yum Repo 10

Press Ok.

Local Yum Repo 11
Local Yum Repo 11

Press Yes to confirm apply the changes.

To check that ftp service is accessible, browse the server from another machine browser.

Local Yum Repo 12
Local Yum Repo 12

Now, update the baseurl in rhel_local to use the ftp protocol.

vi /etc/yum.repos.d/rhel_local.repo
Local Yum Repo 13
Local Yum Repo 13
yum repolist
Local Yum Repo 14
Local Yum Repo 14

Now, the Local Yum Repository has been configured for your network. Just copy the rhel_local.repo file to /etc/yum.repos.d/ to all servers on your network to use it.

Furthermore, we use CentOS 6.5 to demonstrate the configuration. However, the configuration is quite similar in other Linux distros.

Conclusion – CentOS Local Yum Repository:

In this tutorial, you have learned, how to configure CentOS Local Yum Repository.

Leave a Comment