웹사이트 검색

RHEL Linux에서 YUM/DNF를 사용하여 패키지 업데이트를 비활성화하는 방법


DNF(Dandified Yum)는 YUM(Yellowdog Updater, Modified)의 차세대 버전으로, Red Hat 기반 Linux 배포판용 오픈 소스 기본 패키지 관리자로, 가져오기, 설치, 업그레이드, 제거, 공식 소프트웨어 저장소 및 타사 저장소에서 패키지를 쿼리합니다.

시스템을 업데이트하는 동안 Apache 서버(HTTP), MySQL, PHP, 또는 기타 주요 애플리케이션. 이러한 소프트웨어를 업데이트하면 현재 서버에서 실행 중인 웹 애플리케이션이 중단되어 심각한 문제가 발생할 수 있기 때문입니다. 애플리케이션이 새 업데이트로 패치될 때까지 해당 소프트웨어에 대한 업데이트를 중지하는 것이 좋습니다.

이 문서에서는 RHEL과 같은 RPM 기반 배포판에서 YUMDNF 패키지 관리자를 사용하여 특정 패키지 업데이트를 제외(비활성화)하는 방법을 보여줍니다. , CentOS, Fedora, Rocky LinuxAlmaLinux. 또한 타사 리포지토리에서 특정 패키지 업데이트를 제외하거나 비활성화할 수도 있습니다.

제외 구문은 다음과 같습니다.

exclude=package package1 packages*

위의 exclude 지시어는 패키지 목록과 함께 /etc/yum.conf 또는 /etc/dnf/dnf.conf 구성 파일에 정의되어 있습니다. 업데이트 또는 설치에서 제외합니다.

위 구문에서는 '패키지', '패키지1' 및 '패키지' 업데이트 또는 설치 목록을 제외합니다. 패키지를 제외하려면 각 키워드를 공백으로 구분해야 합니다.

YUM 또는 DNF에서 패키지를 제외하는 방법

특정 패키지 업데이트를 제외(비활성화)하려면 원하는 편집기를 사용하여 /etc/yum.conf 또는 /etc/dnf/dnf.conf라는 파일을 엽니다.

vi /etc/yum.conf
OR
vi /etc/dnf/dnf.conf

아래와 같이 exclude 키워드를 사용하여 파일 하단에 다음 줄을 추가합니다.

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release

This is the default, if you make this bigger yum won't see if the metadata 
is newer on the remote and so you'll "gain" the bandwidth of not having to
download the new metadata and "pay" for it by yum not having correct
information.
 It is esp. important, to have correct metadata, for distributions like
Fedora which don't keep old packages around. If you don't like this checking
interupting your command line usage, it's much better to have something
manually check the metadata once an hour (yum-updatesd will do this).
metadata_expire=90m

PUT YOUR REPOS HERE OR IN separate files named file.repo
in /etc/yum.repos.d

## Exclude following Packages Updates ##
exclude=httpd php mysql

위의 예에서 exclude 줄은 “httpd”, “php” 및 “mysql”에 대한 업데이트를 비활성화합니다. 패키지. 아래와 같이 YUM 명령을 사용하여 그중 하나를 설치하거나 업데이트해 보겠습니다.

yum update httpd
OR
dnf update httpd
샘플 출력
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.01link.hk
 * extras: centos.01link.hk
 * updates: mirrors.hns.net.in
base                                                   | 3.7 kB     00:00
extras                                                 | 3.0 kB     00:00
updates                                                | 3.5 kB     00:00
updates/primary_db                                     | 2.7 MB     00:16
Setting up Update Process
No Packages marked for Update

EPEL Repo에서 패키지를 제외하는 방법

EPEL 저장소에서 패키지 설치 또는 업데이트를 제외하려면 /etc/yum.repos.d/epel.repo라는 파일을 엽니다.

vi /etc/yum.repos.d/epel.repo

업데이트에서 제외할 패키지를 지정하여 제외 줄을 추가합니다.

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
## Exclude following Packages Updates ##
exclude=perl php python

이제 표시된 대로 yum/dnf 명령을 사용하여 EPEL 저장소에서 위에 지정된 파일을 업데이트해 보세요.

dnf update perl php python
OR
yum update perl php python
샘플 출력
Last metadata expiration check: 0:00:37 ago on Wednesday 17 November 2021 03:41:28 AM EST.
Package perl available, but not installed.
No match for argument: perl
No match for argument: php
No match for argument: python
Error: No packages marked for upgrade.

또한 yum/dnf 명령줄 옵션을 사용하여 패키지를 저장소 파일에 추가하지 않고 제외할 수도 있습니다.

yum --exclude=httpd update
Or
dnf --exclude=httpd update

패키지 목록을 제외하려면 다음 명령을 사용하십시오.

yum --exclude=mysql\* --exclude=httpd\* update
Or
dnf --exclude=mysql\* --exclude=httpd\* update

이렇게 하면 원하는 패키지의 업데이트를 제외할 수 있습니다. 이를 수행할 수 있는 다른 방법이 많이 있습니다. 예를 들어, 최근 Linux에서 yum 명령을 사용하여 특정 패키지를 차단/비활성화하거나 잠그는 4가지 유용한 방법에 대한 기사를 편집했습니다.