Configure DNF/Yum Mirror Server2022/07/07 |
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 9.
|
|
[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/9/x86_64/os [root@dlp ~]# chmod -R 755 /var/www/repos
# copy from official repository [root@dlp ~]# reposync -p /var/www/repos/centos-stream/9/x86_64/os/ --repo=baseos --download-metadata
[root@dlp ~]#
[root@dlp ~]# reposync -p /var/www/repos/centos-stream/9/x86_64/os/ --repo=appstream --download-metadata
reposync -p /var/www/repos/centos-stream/9/x86_64/os/ --repo=extras-common --download-metadata
|
[4] | Add copy task to daily jobs. |
[root@dlp ~]#
vi /etc/cron.daily/update-repo # create new #!/bin/bash VER='9' ARCH='x86_64' REPOS=(baseos appstream extras-common) 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 success [root@dlp ~]# firewall-cmd --runtime-to-permanent 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.repo # change to local mirror server [baseos] name=CentOS Stream $releasever - BaseOS #metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-$stream&arch=$basearch&protocol=https,http baseurl=http://dlp.srv.world/repos/centos-stream/$releasever/$basearch/os/baseos/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h countme=1 enabled=1 [appstream] name=CentOS Stream $releasever - AppStream #metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-$stream&arch=$basearch&protocol=https,http baseurl=http://dlp.srv.world/repos/centos-stream/$releasever/$basearch/os/appstream/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h countme=1 enabled=1
[root@client ~]#
vi /etc/yum.repos.d/centos-addons.repo # change to local mirror server [extras-common] name=CentOS Stream $releasever - Extras packages #metalink=https://mirrors.centos.org/metalink?repo=centos-extras-sig-extras-common-$stream&arch=$basearch&protocol=https,http baseurl=http://dlp.srv.world/repos/centos-stream/$releasever/$basearch/os/extras-common/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512 gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h countme=1 enabled=1[root@client ~]# dnf clean all [root@client ~]# dnf repolist repo id repo name appstream CentOS Stream 9 - AppStream baseos CentOS Stream 9 - BaseOS extras-common CentOS Stream 9 - Extras packages |
Sponsored Link |
|