Actualizar repositorios yum de centos 7 tras el fin del ciclo de vida (Centos-Base.repo y epel.repo).

Como todos sabeis el fin del ciclo de vida (EOL) de centos 7 llego el 30 de junio de 2024.

La recomendación es migrar el sistema operativo a una versión nueva, pero por diversos motivos puede no interesarnos.

El problema es que al seguir con centos 7 los repositorios han dejado de funcionar y al intentar instalar alguna libreria con yum nos aparecen los siguientes errores:

http://ftp.cica.es/CentOS/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.

To address this issue please refer to the below wiki article

https://wiki.centos.org/yum-errors

If above article doesn't help to resolve this issue please use https://bugs.centos.org/.

http://ftp.dei.uc.pt/pub/linux/CentOS/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.

http://mirror.uv.es/mirror/CentOS/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

Para no tener esos errores y poder seguir instalando librerías con yum solo tenemos que cambiar los repositorios.

Primero borramos todos los repositorios del sistema o los que nos estén dando errores:

rm /etc/yum.repos.d/*

Para a continuación añadir los siguientes ficheros:

Repositorio centos base: /etc/yum.repos.d/CentOS-Base.repo

# base packages for reinstall
[base]
name=CentOS-$releasever - Base
baseurl=https://archive.kernel.org/centos-vault/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://archive.kernel.org/centos-vault/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://archive.kernel.org/centos-vault/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://archive.kernel.org/centos-vault/7.9.2009/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Repositorio: Extra Packages for Enterprise Linux (EPEL): /etc/yum.repos.d/epel.repo

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=http://download.example/pub/epel/7/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch&infra=$infra&content=$contentdir
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=http://download.example/pub/epel/7/$basearch/debug
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch&infra=$infra&content=$contentdir
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place it's address here.
#baseurl=http://download.example/pub/epel/7/source/tree/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch&infra=$infra&content=$contentdir
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

Mostramos el listado de repositorios para confirmar:

[root@localhost ]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirrors.glesys.net
repo id                                                                                            repo name                                                                                                                           status
base/x86_64                                                                                        CentOS-7 - Base                                                                                                                     10,072
epel/x86_64                                                                                        Extra Packages for Enterprise Linux 7 - x86_64                                                                                      13,791
extras/x86_64                                                                                      CentOS-7 - Extras                                                                                                                      526
updates/x86_64                                                                                     CentOS-7 - Updates                                                                                                                   6,173
repolist: 30,562

Y actualizamos para comprobar que esta todo al dia:

[root@localhost]# yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirrors.glesys.net
No packages marked for update