[리눅스] yum 명령어 안될 때 "could not retrieve mirrorlist"

반응형

테스트 환경에서 yum이 실행되지 않았던 부분에 대해서 간단하게 설명드리려 합니다.

 

yum command error

1. 에러 확인

# 외부로 ping도 잘 나가는 상황

[root@localhost ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=115 time=36.7 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=115 time=36.8 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=115 time=37.0 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=115 time=36.2 ms
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 36.260/36.726/37.008/0.313 ms


# yum 명령어를 실행하니 " Could not retrieve mirrorlist ~ " 오류가 발생하였습니다.

[root@localhost ~]# yum list telnet
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 알 수 없는 오류"

 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

 

 

문제 해결

1. nameserver 확인

# nameserver를 확인하세요. 기본적으로 서버에서 네임서버를 조회하지 못한다면 당연히 yum 실행이 안될 수 있습니다.

# 수정 전 (아무런 값이 안나옴)
[root@localhost ~]# cat /etc/resolv.conf   // DNS 설정 하는 걸 깜빡했었다. 

# 수정 후
[root@localhost ~]# cat /etc/resolv.conf
nameserver 8.8.8.8

[root@localhost ~]# yum list telnet   // 정상적으로 실행이 됩니다.
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * extras: mirror.kakao.com
 * updates: mirror.kakao.com
base                                                     | 3.6 kB     00:00
extras                                                   | 2.9 kB     00:00
updates                                                  | 2.9 kB     00:00
(1/4): base/7/x86_64/group_gz                              | 153 kB   00:00
(2/4): extras/7/x86_64/primary_db                          | 206 kB   00:00
(3/4): updates/7/x86_64/primary_db                         | 4.5 MB   00:00
(4/4): base/7/x86_64/primary_db                            | 6.1 MB   00:01
Available Packages
telnet.x86_64                      1:0.17-65.el7_8                       updates

 

2. network 설정 파일 확인

# ifcfg-xxx 파일 확인

[root@localhost ~]# cat /etc/sysconfig/network-script/ifcfg-enp0s3
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=enp0s3
UUID=4c2778dc-5757-412f-b55c-550a3130009b
DEVICE=enp0s3
ONBOOT=yes  // no → yes 변경
IPADDR=192.168.200.192
GATEWAY=192.168.200.254
NETMASK=255.255.255.0
DNS=8.8.8.8  // DNS 설정이 되어 있는지 확인

 

반응형

댓글

Designed by JB FACTORY