30 ноября 2020 года поддержка операционной системы CentOS 6 была прекращена. Кроме отсутствия новых обновлений это событие привело к невозможности использования утилиты yum для работы со списком пакетов.
При попытке выполнения действий yum update, yum install, yum search и т.п. система начала выдавать ошибку:
~]# yum update
Loaded plugins: fastestmirror
Setting up Update Process
Loading mirror speeds from cached hostfile
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base
Решение этой проблемы достаточно простое, Вы сможете убедиться в этом прямо сейчас.
Решение для исправления работы Yum в CentOS 6
Для начала давайте выполним команду:
yum clean all
Это позволит сбросить все кэши и в дальнейшем избавит от возможных проблем.
Теперь откроем файл /etc/yum.repos.d/CentOS-Base.repo и закомментируем строки «mirrorlist=…» и «baseurl=…»
Т.е. перед ними поставим символ «#» и в результате получим:
#mirrorlist=...
#baseurl=...
Ниже этих двух строк добавляем в каждую секцию baseurl, в котором в качестве хоста указываем https://vault.centos.org, остальные параметры из старого baseurl и сохраняем результат, например:
baseurl=https://vault.centos.org/centos/$releasever/os/$basearch/
В результате для каждой секции файла у нас будет 5 разных вариаций:
baseurl=https://vault.centos.org/centos/$releasever/os/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/updates/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/extras/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/contrib/$basearch/
Полный файл /etc/yum.repos.d/CentOS-Base.repo будет иметь примерно следующий вид:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Вот и все! Теперь Вы сможете ввести любую команду yum (yum install, yum update, yum search…) и насладится прежней работой.
При этом помните, что обновления для CentOS 6 с 30 ноября 2020 года больше не выпускаются, а хостинг VPS/VDS или Dedicated сервер лучше заказывать у хостинг-провайдера Хост.SU.
P.S. Если у Вас в системе установлен Perl, то для быстрой правки файла Вы можете выполнить всего лишь три команды:
perl -pi -e 's/mirrorlist=/#mirrorlist=/' /etc/yum.repos.d/CentOS-Base.repo
perl -pi -e 's/http://mirror.centos.org/https://vault.centos.org/' /etc/yum.repos.d/CentOS-Base.repo
perl -pi -e 's/#baseurl=/baseurl=/' /etc/yum.repos.d/CentOS-Base.repo
P.S.S. При наличии утилиты «sed» можно выполнить:
sed -i 's/mirrorlist=/#mirrorlist=/' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/http://mirror.centos.org/https://vault.centos.org/' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/#baseurl=/baseurl=/' /etc/yum.repos.d/CentOS-Base.repo
Одной из самых распространенных ошибок, с которыми пользователи CentOS сталкиваются при использовании диспетчера пакетов YUM (например, при запуске команды обновления yum), особенно в недавно установленной системе, является «“Cannot find a valid baseurl for repo: base/7/x86_64”.».
В этой короткой статье мы покажем, как исправить ошибку “Cannot find a valid baseurl for repo в дистрибутиве CentOS Linux.
На следующем снимке экрана показана вышеупомянутая ошибка после выполнения команды yum для поиска пакета.
# yum search redis
Ошибка указывает на то, что YUM не может получить доступ к базовому репозиторию, который он использует для поиска информации о пакете.
В большинстве случаев возможны две причины ошибки: 1) проблемы с сетью и / или 2) базовый URL закомментирован в файле конфигурации репозитория.
Вы можете исправить эту ошибку следующими способами:
1. Убедитесь, что ваша система подключена к Интернету.
Вы можете попробовать пропинговать любое интернет-направление, например, google.com.
# ping google.com
Результат проверки связи указывает либо на проблему DNS, либо на отсутствие подключения к Интернету.
В этом случае попробуйте отредактировать файлы конфигурации сетевого интерфейса.
Чтобы определить сетевой интерфейс, выполните команду ip.
# ip add
Чтобы изменить конфигурацию интерфейса enp0s8, откройте файл /etc/sysconfig/network-scripts/ifcfg-enp0s8, как показано далее:
# vi /etc/sysconfig/network-scripts/ifcfg-enp0s8
Если это проблема DNS, попробуйте добавить серверы имен в файл конфигурации, как показано на рисунке.
DNS1=10.0.2.2 DNS2=8.8.8.8
Затем перезапустите службу Network Manager с помощью команды systemctl.
# systemctl restart NetworkManager
Для получения дополнительной информации прочитайте нашу статью:
Как добавить сетевой шлюз или статический маршрут на CentOS / RHEL 6, 7
После внесения изменений в настройки сети попробуйте еще раз запустить пинг.
# ping google.com
Теперь выполните попытку еще раз запустить обновление yum или любую команду yum, которая показала вышеуказанную ошибку.
# yum search redis
2. Если система подключена к Интернету и DNS работает нормально, то должна быть проблема с файлом конфигурации репозитория /etc/yum.repos.d/CentOS-Base.repo.
Откройте файл, используя ваш любимый редактор командной строки.
# vi /etc/yum.repos.d/CentOS-Base.repo
Найдите раздел [base], попробуйте раскомментировать baseurl, удалив начальный символ # в строке baseurl, как показано на следующем снимке экрана.
Сохраните изменения и закройте файл.
Теперь попробуйте снова запустить команду yum.
# yum update
В этой статье мы объяснили, как исправить ошибку «Cannot find a valid baseurl for repo:» в CentOS 7.
Мы хотели бы услышать ваше мнение.
Вы также можете поделиться решениями, которые вы знаете, чтобы решить эту проблему, с помощью формы обратной связи ниже.
This might be caused by two possibilities.
1. Repo too old to find
Base on your centos version, I tried to find the os via the link. And getting this information from readme file.
This directory (and version of CentOS) is deprecated. For normal users,
you should use /5/ and not /5.9/ in your path. Please see this FAQ
concerning the CentOS release scheme:https://wiki.centos.org/FAQ/General
If you know what you are doing, and absolutely want to remain at the 5.9
level, go to http://vault.centos.org/ for packages. Please keep in mind that 5.9 no longer gets any updates
In this link, it suggest you to find old version via another link. Thus, you need to modify CentOS-Base.repo.
Replacing all http://mirror.centos.org/centos/***
into http://vault.centos.org/***
.
for example:
Original: baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
New: baseurl=http://vault.centos.org/$releasever/os/$basearch/
2. Network Issue
checking the mirrorlist server
is accessible.
$ ping mirrorlist.centos.org
If you might meet the error message below.
ping: unknown host mirrorlist.centos.org
To solve this, adding a valid nameserver into resolv.conf
(use sudo if you are not root user)
$ echo nameserver 8.8.8.8 > /etc/resolv.conf
I am using Centos 7.1.1503 (core) as a VM. The host OS is Windows 10. I created this VM so this is a fresh installation of CentOS. My laptop has a direct connection to the internet, without a proxy.
When I execute the command yum update all
I get with the error
Cannot find a valid baseurl for repo: base/7/x86_64
I went through various threads related to this error on Stackexchange.com and tried all the below suggestions:
-
executed
dhclient
. -
Edited
ifcfg-enp0s3
with information, as suggested in this question -
Uncommented the baseURL from the
/etc/yum.repos.d/CentOS-Base.repo
file
If I change the VirtualBox network settings to use «NAT», then I can see that yum is working without any issues. I can keep this setting, but I will not be able to access CentOS from my host OS, which is why I had used «Bridge» networking. When I use «Bridge» I am having this issue.
One of the commonest errors CentOS users encounter when using YUM package manager (for example running yum update command), especially on a freshly installed system is the “Cannot find a valid baseurl for repo: base/7/x86_64”.
In this short article, we will show how to fix “cannot find a valid baseurl for repo” error in CentOS Linux distribution.
The following screenshot shows the above error after running a yum command to search for a package.
# yum search redis
The error indicates that YUM is not capable of accessing the base repository that it uses to find package information. In most cases, there are two possible causes of the error: 1) network issues and/or 2) base URL being commented out in the repository configuration file.
You can fix this error in the following ways:
1. Make sure that your system is connected to the Internet. You can try to ping any internet direction, for example, google.com.
# ping google.com
The ping result indicates either a DNS problem or no Internet connectivity. In this case, try to edit network interface configuration files. To identify your network interface, run the ip command.
# ip add
To edit the configuration for interface enp0s8, open the file /etc/sysconfig/network-scripts/ifcfg-enp0s8 as shown.
# vi /etc/sysconfig/network-scripts/ifcfg-enp0s8
If it is a DNS problem, try to add the Nameservers in the configuration file as shown.
DNS1=10.0.2.2 DNS2=8.8.8.8
Then restart the Network Manager service with the systemctl command.
# systemctl restart NetworkManager
For more information, read our article: How to Configure Network Static IP Address and Manage Services on RHEL/CentOS 7.0.
After making changes in the network settings, try to run a ping once more.
# ping google.com
Now run try to run the yum update or the any yum command that was showing the above error, once more.
# yum search redis
2. If the system is connected to the Internet and DNS is working fine, then there should be an issue with the repo configuration file /etc/yum.repos.d/CentOS-Base.repo.
Open the file using your favorite command-line editor.
# vi /etc/yum.repos.d/CentOS-Base.repo
Look for the [base]
section, try uncommenting the baseurl
by removing the leading #
on the baseurl line as shown in the following screenshot.
Save the changes and close the file. Now try to run yum command again.
# yum update
In this article, we have explained how to fix the “Cannot find a valid baseurl for repo:” error in CentOS 7. We would like to hear from you, share your experience with us. You can also share solutions you know to fix this issue, via the feedback form below.
If you read this far, tweet to the author to show them you care. Tweet a thanks
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.
Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.