[8] DNF/Yum – lokalny obraz repozytoriów

20 marca 2022 Wyłączono przez Adam [zicherka] Nogły

Skonfiguruj lokalny serwer repozytorium DNF/Yum, aby szybciej aktualizować pakiety dla serwerów lokalnych.

W tym przykładzie skonfiguruj repozytoria lustrzane [BaseOS], [AppStream], [Extras], które są domyślnie włączone w CentOS Stream 8.

[1] Zainstaluj i uruchom serwer httpd Apache, patrz tutaj.

[2] Zainstaluj inne wymagane pakiety.

[root@vlsr05 ~]# dnf install yum-utils

[3] Utwórz katalogi dla repozytorium i skopiuj dane z oficjalnego repozytorium CentOS Stream.

[root@vlsr05 ~]# mkdir -p /var/www/repos/centos-stream/8/x86_64/os
[root@vlsr05 ~]# chmod -R 755 /var/www/repos

# skopiuj z oficjalnego repozytorium
[root@vlsr05 ~]# reposync -p /var/www/repos/centos-stream/8/x86_64/os/ --repo=baseos --download-metadata
[root@vlsr05 ~]# reposync -p /var/www/repos/centos-stream/8/x86_64/os/ --repo=apownload-metadata
[root@vlsr05 ~]# reposync -p /var/www/repos/centos-stream/8/x86_64/os/ --repo=extras --download-metadata

[4] Dodaj zadanie kopiowania do codziennych zadań.

[root@vlsr05 ~]# mcedit /etc/cron.daily/update-repo
# stwórz nowy
#!/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

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

[5] Skonfiguruj serwer httpd Apache, aby zapewnić repozytorium dla innych hostów/klientów w sieci lokalnej.

[root@vlsr05 ~]# mcedit /etc/httpd/conf.d/repos.conf
# stwórz nowy
Alias /repos /var/www/repos
<directory /var/www/repos>
    Options +Indexes
    Require all granted
</directory>

[6] Jeśli Firewalld jest uruchomiony, zezwól na usługę HTTP.

[root@vlsr05 ~]# firewall-cmd --add-service=http --permanent
[root@vlsr05 ~]# firewall-cmd –reload

[7] Na hostach klienta zmień ustawienia DNF/Yum, aby odnieść się do lokalnego hosta lustrzanego z repozytoriami DNF/Yum.

[root@vlsr04 ~]# mcedit /etc/yum.repos.d/CentOS-Stream-BaseOS.repo
# zmień na lokalny serwer lustrzany
[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://vlsr05.zicher.lab/repos/centos-stream/$releasever/$basearch/os/baseos/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[root@vlsr04 ~]# mcedit /etc/yum.repos.d/CentOS-Stream-AppStream.repo
# zmień na lokalny serwer lustrzany
[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://vlsr05.zicher.net/repos/centos-stream/$releasever/$basearch/os/appstream/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[root@vlsr04 ~]# mcedit /etc/yum.repos.d/CentOS-Stream-Extras.repo
# zmień na lokalny serwer lustrzany
[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://vlsr05.zicher.lab/repos/centos-stream/$releasever/$basearch/os/extras/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[root@vlsr04 ~]# dnf repolist
identyfikator repozytorium      nazwa repozytorium
appstream                       CentOS Stream 8 - AppStream
baseos                          CentOS Stream 8 - BaseOS
extras                          CentOS Stream 8 – Extras

[root@vlsr04 ~]# dnf module list | head
Ostatnio sprawdzono ważność metadanych: 0:00:25 temu w dniu nie, 20 mar 2022, 00:05:56.
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]                               Most recent (rolling) versions of podman, buildah, skopeo, runc, conmon, runc, conmon, CRIU, Udica, etc as well as dependencies such as container-selinux built and tested together, and updated as frequently as every 12 weeks.
container-tools      1.0             common [d]                               Stable versions of podman 1.0, buildah 1.5, skopeo 0.1, runc, conmon, CRIU, Udica, etc as well as dependencies such as container-selinux built and tested together, and supported for 24 months.
container-tools      2.0             common [d]                               Stable versions of podman 1.6, buildah 1.11, skopeo 0.1, runc, conmon, etc as well as dependencies such as container-selinux built and tested together, and supported as documented on the Application Stream lifecycle page.
container-tools      3.0             common [d]                               Stable versions of podman 3.0, buildah 1.19, skopeo 1.2, runc, conmon, etc as well as dependencies such as container-selinux built and tested together, and supported as documented on the Application Stream lifecycle page.
container-tools      4.0             common                                   Most recent (rolling) versions of podman, buildah, skopeo, runc, conmon, runc, conmon, CRIU, Udica, etc as well as dependencies such as container-selinux built and tested together, and updated as frequently as every 12 weeks.
. . . . .