Create a local yum repository on CentOS/RHEL 7.x

From where is the need for a local repository?
Let’s say we have 1000 VMs that need to be reinstalled via network or install critical patches; this will clog the WAN and take more time than you would expect. If you use the private repository you will benefit from the full speed and throughput of your internal network while flooding the wan for deltas only a few times a day.

Install createrepo
yum -y install createrepo

Install nginx for web access
yum -y install nginx

Set 'autoindex on' for nginx in /etc/nginx/nginx.conf

Create directory structure
mkdir -p /usr/share/nginx/html/repo/centos/7/os/x86_64

Rsync repo from external source
cd /usr/share/nginx/html/repo/centos/7/os/x86_64 && \
    rsync -avrz --progress rsync://* .

Optional : if repodata is missing
createrepo .

Point your yum.repos.d/*.repo to your local ones

'yum clean all' after repos were modified

Install your packages from the new created repository.

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

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