CentOS 8
Sponsored Link

Configure DNF/Yum Mirror Server2020/03/12

 
Configure Local DNF/Yum Repository Server to update packages faster for local Servers.
On this example, Configure [baseos], [appstream], [extras] mirror repositories that are enabled by default on CentOS 8.
[1]
[2] Install other required packages.
[root@dlp ~]#
dnf -y install yum-utils
[3] Create directories for repository and copy data from CentOS official Repository.
[root@dlp ~]#
mkdir -p /var/www/repos/centos/8/x86_64/os

[root@dlp ~]#
chmod -R 755 /var/www/repos
# copy from official repository

[root@dlp ~]#
reposync -p /var/www/repos/centos/8/x86_64/os/ --repo=baseos --download-metadata
[root@dlp ~]#
reposync -p /var/www/repos/centos/8/x86_64/os/ --repo=appstream --download-metadata
[root@dlp ~]#
reposync -p /var/www/repos/centos/8/x86_64/os/ --repo=extras --download-metadata
[4] Add copy task to daily jobs.
[root@dlp ~]#
vi /etc/cron.daily/update-repo
# create new

#!/bin/bash

VER='8'
ARCH='x86_64'
REPOS=(baseos appstream extras)

for REPO in ${REPOS[@]}
do
    reposync -p /var/www/repos/centos/${VER}/${ARCH}/os/ --repo=${REPO} --download-metadata --newest-only
done

[root@dlp ~]#
chmod 755 /etc/cron.daily/update-repo

[5] Configure Apache httpd to provide repository for other Client Hosts.
[root@dlp ~]#
vi /etc/httpd/conf.d/repos.conf
# create new

Alias /repos /var/www/repos
<directory /var/www/repos>
    Options +Indexes
    Require all granted
</directory>

[root@dlp ~]#
systemctl restart httpd

[6] If Firewalld is running, allow HTTP service.
[root@dlp ~]#
firewall-cmd --add-service=http --permanent

success
[root@dlp ~]#
firewall-cmd --reload

success
[7] On Client Hosts, Change settings of DNF/Yum to refer to Local DNF/Yum Mirror Host.
[root@client ~]#
vi /etc/yum.repos.d/CentOS-Base.repo
# change to local mirror server

[baseos]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=baseos&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/baseos/$basearch/os/
baseurl=http://dlp.srv.world/repos/centos/$releasever/$basearch/os/baseos/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[root@client ~]#
vi /etc/yum.repos.d/CentOS-appstream.repo
[appstream]
name=CentOS-$releasever - appstream
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=appstream&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/appstream/$basearch/os/
baseurl=http://dlp.srv.world/repos/centos/$releasever/$basearch/os/appstream/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[root@client ~]#
vi /etc/yum.repos.d/CentOS-Extras.repo
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/extras/$basearch/os/
baseurl=http://dlp.srv.world/repos/centos/$releasever/$basearch/os/extras/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[root@dlp ~]#
dnf repolist

CentOS-8 - appstream                            145 MB/s | 6.5 MB     00:00
CentOS-8 - Base                                 159 MB/s | 5.0 MB     00:00
CentOS-8 - Extras                               543 kB/s | 2.1 kB     00:00
repo id                        repo name                                  status
appstream                      CentOS-8 - appstream                       5,103
baseos                         CentOS-8 - Base                            2,107
extras                         CentOS-8 - Extras                              3

[root@node01 ~]#
dnf module list

CentOS-8 - appstream
Name                 Stream      Profiles Summary
389-ds               1.4         389 Directory Server (base)
ant                  1.10 [d]    common [d] Java build tool
container-tools      rhel8 [d]   common [d] Common tools and dependencies for container runtimes
container-tools      1.0         common [d] Common tools and dependencies for container runtimes
freeradius           3.0 [d]     server [d] High-performance and highly configurable free RADIUS server
.....
.....
varnish              6 [d]       common [d] Varnish HTTP cache
virt                 rhel [d][e] common [d] Virtualization module

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
Matched Content