OS/Linux

[Linux] yum install 오류 해결법

Dev.Congsik 2024. 9. 4. 13:08
728x90
  • 리눅스 로컬 서버(Centos7)에서 yum으로 install 테스트 중 아래와 같은 에러가 발생했다.
[root@test1 ~]# yum install htop
Loaded plugins: fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"


 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

 

 

=> 대강 읽어보면 mirrorlist가 유효하지 않다, repository 구성 실패, 유효한 baseurl을 찾을 수 없다 등의 내용이다.

 

  • 원인을 구글링해보니 Centos 7이 EOL되어 기존에 있던 레포지토리 내 파일들이 사라졌기 때문에, 기존 정보로는 원활하게 동작하지 않아 발생한 이슈였다.

Redhat 공식 홈페이지에 명시된 내용

==> 관련 링크 - https://www.redhat.com/ko/topics/linux/centos-linux-eol

 

CentOS Linux의 End of Life (EOL) 필수 정보 요약

CentOS Linux 7의 지원 종료 (End of Life, EOL)는 2024년 6월 30일입니다. 이에 대한 준비 상황과 Red Hat의 마이그레이션 지원 방법을 알아봅니다

www.redhat.com

 

  • 해결법으로 yum repository를 수정하면 된다는 정보를 입수했다.

<참고 정보 링크>

출처 - https://developer-woong.tistory.com/112

 

  • yum.repos.d 이동
cd /etc/yum.repos.d

기존 repo 목록

 

 

  • 기존 repo 백업
mkdir old_repo

mv CentOS* old_repo

 

 

  • 새 repository 파일 생성
vi CentOS-Base.repo

[base]
name=CentOS-$releasever - Base
# original
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
# new
baseurl=http://centos.mirror.cdnetworks.com/7/os/x86_64
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
# original
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
# new
baseurl=http://centos.mirror.cdnetworks.com/7/updates/x86_64
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
# original
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
# new
baseurl=http://centos.mirror.cdnetworks.com/7/extras/x86_64
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
# original
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
# new
baseurl=http://centos.mirror.cdnetworks.com/7/centosplus/x86_64
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

 

  • yum 캐시 삭제
yum clean all

 

  • yum 설치 테스트
[root@test1 yum.repos.d]# yum install -y htop
Loaded plugins: fastestmirror
Determining fastest mirrors
base                                                                                                                                                                                                                  | 3.6 kB  00:00:00
extras                                                                                                                                                                                                                | 3.4 kB  00:00:00
updates                                                                                                                                                                                                               | 3.4 kB  00:00:00
(1/4): base/group_gz                                                                                                                                                                                                  | 166 kB  00:00:00
(2/4): extras/primary_db                                                                                                                                                                                              | 156 kB  00:00:00
(3/4): updates/primary_db                                                                                                                                                                                             | 1.3 MB  00:00:00
(4/4): base/primary_db                                                                                                                                                                                                | 6.0 MB  00:00:00
No package htop available.
Error: Nothing to do

 

 

728x90

'OS > Linux' 카테고리의 다른 글

[Linux] 리눅스마스터 1급 필기 기출  (14) 2024.10.16
[Linux] 서버 리소스 모니터링  (0) 2024.09.04
[Linux] vi 편집기 명령어  (0) 2024.08.28
[Linux] cron 표현식  (0) 2024.08.27
[Linux] 서버시간 동기화 - ntp  (0) 2024.08.27