🤾♂️ «Yum clean all» не очищает кэш репозитория yum в CentOS / RHEL / OEL

by itisgood

Проблема

«Yum clean all» не очищает информацию о кэше yum в /var/cache/yum сервера Orcle Linux, который использует общедоступный репозиторий Oracle или локальный репозиторий yum.

# yum repolist
Loaded plugins: refresh-packagekit, security, ulninfo
public_ol6_UEK_latest | 1.2 kB 00:00
public_ol6_UEK_latest/primary | 26 MB 00:04
public_ol6_UEK_latest 554/554
public_ol6_latest | 1.4 kB 00:00
public_ol6_latest/primary | 58 MB 00:04
public_ol6_latest 36051/36051
repo id repo name status
public_ol6_UEK_latest Latest Unbreakable Enterprise Kernel for Oracle Linux 6Ser 554
public_ol6_latest Oracle Linux 6Server Latest (x86_64) 36,051
repolist: 36,605
# du -sh /var/cache/yum/x86_64/6Server/*
864K /var/cache/yum/x86_64/6Server/ol6_addons
973M /var/cache/yum/x86_64/6Server/ol6_latest
367M /var/cache/yum/x86_64/6Server/ol6_UEK_latest
12K /var/cache/yum/x86_64/6Server/public_ol6_latest
8.0K /var/cache/yum/x86_64/6Server/public_ol6_UEK_latest
45MB /var/cache/yum/x86_64/6Server/public_ol6_UEKR3_latest
# yum clean all
Loaded plugins: refresh-packagekit, security, ulninfo
Cleaning repos: public_ol6_UEK_latest public_ol6_latest
Cleaning up Everything
# du -sh /var/cache/yum/x86_64/6Server/*
864K /var/cache/yum/x86_64/6Server/ol6_addons
973M /var/cache/yum/x86_64/6Server/ol6_latest
367M /var/cache/yum/x86_64/6Server/ol6_UEK_latest
12K /var/cache/yum/x86_64/6Server/public_ol6_latest
8.0K /var/cache/yum/x86_64/6Server/public_ol6_UEK_latest
45MB /var/cache/yum/x86_64/6Server/public_ol6_UEKR3_latest

Решение

«Yum clean» удаляет кеш репозиториев, которые включены в /etc/yum.repos.d/*.repo. Из справочной страницы yum:

# man yum
....

CLEAN OPTIONS

The following are the ways which you can invoke yum in clean mode. Note that "all files" in the commands below means "all files in currently enabled
repositories". If you want to also clean any (temporarily) disabled repositories you need to use --enablerepo=’*’ option.

Для устранения неполадок выполните следующие действия:

1. Временно включите репозитории, чтобы очистить кэш yum.

# yum clean all --enablerepo="repository_label"

или

# vi /etc/yum.repos.d/[filename].repo
...
enabled = 1    ### Add this for the respective repository.

Что делать, если в файле /etc/yum.repos.d/*.repo нет информации о репозитории?

В этом случае временная запись в файле репозитория с именем метки репозитория поможет очистить кэш.

Отладка

В следующем примере включены только два репозитория, т. е. «Public_ol6_UEK_latest, public_ol6_latest», тогда как информация кэша yum доступна для нескольких дополнительных репозиториев.

Предположим, что репозиторий «public_ol6_UEKR3_latest» отключен, а у «ol6_UEK_latest, ol6_latest» нет записи в файле /etc/yum.repos.d/*.repo.

# yum repolist

Loaded plugins: refresh-packagekit, security, ulninfo
public_ol6_UEK_latest | 1.2 kB 00:00
public_ol6_UEK_latest/primary | 26 MB 00:04
public_ol6_UEK_latest 554/554
public_ol6_latest | 1.4 kB 00:00
public_ol6_latest/primary | 58 MB 00:04
public_ol6_latest 36051/36051
repo id repo name status
public_ol6_UEK_latest Latest Unbreakable Enterprise Kernel for Oracle Linux 6Ser 554
public_ol6_latest Oracle Linux 6Server Latest (x86_64) 36,051
repolist: 36,
# du -sh /var/cache/yum/x86_64/6Server/*
864K /var/cache/yum/x86_64/6Server/ol6_addons
973M /var/cache/yum/x86_64/6Server/ol6_latest
367M /var/cache/yum/x86_64/6Server/ol6_UEK_latest
12K /var/cache/yum/x86_64/6Server/public_ol6_latest
8.0K /var/cache/yum/x86_64/6Server/public_ol6_UEK_latest
45MB /var/cache/yum/x86_64/6Server/public_ol6_UEKR3_latest

Очистите информацию кеша отключенного репозитория, который имеет запись в файле /etc/yum.repos.d/*.repo. то есть public_ol6_UEKR3_latest:

# yum clean all --enablerepo="public_ol6_UEKR3_latest"
# du -sh /var/cache/yum/x86_64/6Server/*
864K /var/cache/yum/x86_64/6Server/ol6_addons
973M /var/cache/yum/x86_64/6Server/ol6_latest
367M /var/cache/yum/x86_64/6Server/ol6_UEK_latest
12K /var/cache/yum/x86_64/6Server/public_ol6_latest
8.0K /var/cache/yum/x86_64/6Server/public_ol6_UEK_latest
12K /var/cache/yum/x86_64/6Server/public_ol6_UEKR3_latest

Чтобы очистить кэш двух других репозиториев, у которых нет записи в «/etc/yum.repos.d/*.repo», его можно удалить вручную или добавить временную запись в конфигурационном файле.

# rm -rf /var/cache/yum/x86_64/6Server/ol6_latest /var/cache/yum/x86_64/6Server/ol6_latest

или

# vi /etc/yum.repos.d/public.repo
[ol6_latest]
enabled = 1

[ol6_UEK_latest]    
enabled = 1
# yum clean all
# du -sh /var/cache/yum/x86_64/6Server/*

864K /var/cache/yum/x86_64/6Server/ol6_addons
12.0K /var/cache/yum/x86_64/6Server/ol6_latest
8.0K /var/cache/yum/x86_64/6Server/ol6_UEK_latest
12K /var/cache/yum/x86_64/6Server/public_ol6_latest
8.0K /var/cache/yum/x86_64/6Server/public_ol6_UEK_latest
12K /var/cache/yum/x86_64/6Server/public_ol6_UEKR3_latest

 

You may also like

Leave a Comment