Di recente ho esplorato l'aggiornamento di CentOS 7 a CentOS 8 e durante il processo ho riscontrato l'errore:Impossibile sincronizzare la cache per il repository 'appstream' . Di seguito è riportato l'errore completo:
Failed to synchronize cache for repo 'baseos', ignoring this repo. Failed to synchronize cache for repo 'appstream', ignoring this repo.
Output da /var/log/dnf.log
per ulteriori informazioni sul DEBUG:
2022-02-15T10:09:08Z DEBUG repo: downloading from remote: appstream 2022-02-15T10:09:08Z DEBUG Cannot download 'http://mirror.centos.org/centos/8/AppStream/x86_64/os/': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried. 2022-02-15T10:09:08Z DEBUG repo: downloading from remote: extras 2022-02-15T10:09:08Z DEBUG not found other for: CentOS Linux 8 - Extras 2022-02-15T10:09:08Z DEBUG not found modules for: CentOS Linux 8 - Extras 2022-02-15T10:09:08Z DEBUG not found deltainfo for: CentOS Linux 8 - Extras 2022-02-15T10:09:08Z DEBUG not found updateinfo for: CentOS Linux 8 - Extras 2022-02-15T10:09:08Z DEBUG extras: using metadata from Fri 10 Dec 2021 06:26:25 PM IST. 2022-02-15T10:09:08Z WARNING Failed to synchronize cache for repo 'baseos', ignoring this repo. 2022-02-15T10:09:08Z WARNING Failed to synchronize cache for repo 'appstream', ignoring this repo.
Guardando il messaggio di errore, ho pensato che il problema potesse essere dovuto alla connessione Internet. Tuttavia, la connessione Internet e il DNS hanno funzionato perfettamente come mostrato di seguito.
[root@upgrade-centos log]# ping google.com PING google.com (172.217.166.206) 56(84) bytes of data. 64 bytes from del03s13-in-f14.1e100.net (172.217.166.206): icmp_seq=1 ttl=115 time=44.10 ms ^C --- google.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 44.971/44.971/44.971/0.000 ms
Quindi come ho risolto il problema? Eccolo.
Come risolvere Impossibile sincronizzare la cache per il repo appstream
Potrebbero esserci più ragioni per questo problema. I più comuni sono:
- Impostazioni di data e ora errate
- Vecchio
dnf
cache disponibile o scaduta - URL di base CentOS
Come correggere le impostazioni di data e ora errate
Il timedatectl
command è un nuovo strumento di utilità in CentOS 7/8. È un sostituto della vecchia date
tradizionale comando utilizzato in sysvinit
distribuzioni Linux basate su demoni.
Trova la data e l'ora correnti del tuo sistema. Assicurati che sia corretto con il fuso orario corretto.
[root@upgrade-centos ~]# timedatectl Local time: Tue 2022-02-15 11:24:25 UTC Universal time: Tue 2022-02-15 11:24:25 UTC RTC time: Tue 2022-02-15 11:24:25 Time zone: UTC (UTC, +0000) System clock synchronized: no NTP service: active RTC in local TZ: no
Imposta il tuo fuso orario
[root@upgrade-centos ~]# timedatectl set-timezone "Asia/Kolkata" [root@upgrade-centos ~]# date Tue Feb 15 16:58:57 IST 2022
Come cancellare la cache dnf vecchia/scaduta
Ecco un articolo per pulire ogni tipo di cache. Per pulirlo tutto, esegui il comando seguente:
[root@upgrade-centos ~]# dnf clean all [root@upgrade-centos ~]# rm -rf /var/cache/dnf
Come modificare CentOS baseURL da mirror.centos.org a vault.centos.org
CentOS Linux 8 ha raggiunto la fine della vita (EOL) il 31 dicembre 2021. Significa che CentOS 8 non riceverà più risorse di sviluppo dal progetto CentOS ufficiale. Dopo il 31 dicembre 2021, se devi aggiornare CentOS, devi cambiare i mirror in vault.centos.org dove verranno archiviati in modo permanente. In alternativa, puoi eseguire l'upgrade a CentOS Stream o migrare da CentOS a Rocky Linux.
Vai a /etc/yum.repos.d/
directory.
[root@autocontroller ~]# cd /etc/yum.repos.d/
Esegui i comandi seguenti
[root@autocontroller ~]# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
[root@autocontroller ~]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
Ora esegui dnf update
[root@autocontroller ~]# dnf update
Questo è tutto!