Configure DNF/Yum Mirror Server2021/04/15 |
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 Stream 8.
|
|
[1] | |
[2] | Install other required packages. |
[root@dlp ~]# dnf -y install yum-utils
|
[3] | Create directories for repository and copy data from CentOS Stream official Repository. |
[root@dlp ~]#
mkdir -p /var/www/repos/centos-stream/8/x86_64/os [root@dlp ~]# chmod -R 755 /var/www/repos
# copy from official repository [root@dlp ~]# reposync -p /var/www/repos/centos-stream/8/x86_64/os/ --repo=baseos --download-metadata
[root@dlp ~]#
[root@dlp ~]# reposync -p /var/www/repos/centos-stream/8/x86_64/os/ --repo=appstream --download-metadata
reposync -p /var/www/repos/centos-stream/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-stream/${VER}/${ARCH}/os/ --repo=${REPO} --download-metadata --newest-only done 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> 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-Stream-BaseOS.repo # change to local mirror server [baseos] name=CentOS Stream $releasever - BaseOS #mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=BaseOS&infra=$infra #baseurl=http://mirror.centos.org/$contentdir/$stream/BaseOS/$basearch/os/ baseurl=http://dlp.srv.world/repos/centos-stream/$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-Stream-AppStream.repo # change to local mirror server [appstream] name=CentOS Stream $releasever - AppStream #mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=AppStream&infra=$infra #baseurl=http://mirror.centos.org/$contentdir/$stream/AppStream/$basearch/os/ baseurl=http://dlp.srv.world/repos/centos-stream/$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-Stream-Extras.repo # change to local mirror server [extras] name=CentOS Stream $releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=extras&infra=$infra #baseurl=http://mirror.centos.org/$contentdir/$stream/extras/$basearch/os/ baseurl=http://dlp.srv.world/repos/centos-stream/$releasever/$basearch/os/extras/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial[root@dlp ~]# dnf repolist repo id repo name appstream CentOS Stream 8 - AppStream baseos CentOS Stream 8 - BaseOS extras CentOS Stream 8 - Extras[root@node01 ~]# dnf module list CentOS Stream 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 |
Sponsored Link |
|