지난번에 AWS EC2 서비스를 이용하여 centos 7 환경에서 리눅스 공부를 할 수 있도록 환경 설정을 마쳤다.
내가 서버에 접속하자 마자 했던 일은, make, gcc, git의 설치 유무를 확인하고, 존재하지 않는다면 yum을 통하여 설치하는 일이었다.
git을 제외한 make 및 gcc를 포함하는 많은 개발툴이 "Development Tools" 그룹의 설치로 한 번에 해결할 수 있었는데, 문제는 여기부터 발생하였다.
redhat이 2024년 6월 30일부로 centos 7 지원을 종료했다는 것이었다. (https://www.redhat.com/ko/engage/centos-migration-level-up)
이로 인해서 centos 7 환경에서 yum install을 진행하면, 다음과 같이 mirrorlist.centos.org 호스트를 찾을 수 없다는 오류와 함께 패키지 install이 되지 않는다. 아래는 해당 오류 전문이다.
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=genclo 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
이 오류 때문에 한참을 해멨는데, Centos 7이 공식적으로 지원을 종료하면서, 원래 지원하던 서버 리포지토리에 접근할 수 없게 되며 생기는 문제가 아닐까 싶다.
결국 해결 방안은, 원래 사용하던 레파지토리 서버가 지원을 종료했으므로, 레파지토리 URL을 다른 것으로 변경하면 된다는 것 이다.
나는 해당 게시글을 참고하여 오류를 해결하였으나, 같은 방식으로 오류를 해결한
해당 게시글도, 문제 해결에 도움이 되지 않을까 싶다.
내가 문제를 해결한 게시글에서는,
[root@instance-juyeon ~]# cd /etc/yum.repos.d
## 기존 yum 관련 레파지토리 백업 폴더 생성 및 이동
[root@instance-juyeon yum.repos.d]# mkdir backup
[root@instance-juyeon yum.repos.d]# mv CentOS-* backup
이렇게 yum.repos.d에 존재하던 파일을 전부 없애버리고(backup 폴더 생성 후 전부 이동)
## 새 레파지토리 파일 생성
[root@instance-juyeon yum.repos.d]# vi CentOS-BASE.repo
[base]
name=CentOS-$releasever - Base
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
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
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
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
새 레파지토리 파일을 생성하여, 정상작동하는 URL로 갈아끼워주는 것으로 오류를 해결했다.
원래 존재하던 CentOS-BASE.repo 파일의 내용과 비교해 보니, mirrorlist 항목을 전부 삭제하고, baseurl을 바꾸어 오류를 해결한 것을 확인할 수 있었다.
[root@instance-juyeon yum.repos.d]# yum clean all
마지막으로는 yum cache를 삭제해주며 마무리 한다.
이 단계를 모두 거치면, 적어도 앞으로
curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
이 무서운 오류를 마주할 일은 없을 것이다.
레파지토리 url 오류를 해결한 후, 아무런 문제도 마주하지 않을 줄 알았건만, 역시 리눅스의 세계는 그렇게 호락호락하지 않았다.
yum group install "Development Tools"
명령어를 이용하여, 개발에 필요한 도구들을 한 번에 다운받을 수 있을 줄 알았건만...
한 번에 대량의 오류들과 마주하고 만다.
Error: Package: libstdc++-devel-4.8.5-36.el7.x86_64 (base)
Requires: libstdc++(x86-64) = 4.8.5-36.el7
Installed: libstdc++-4.8.5-44.el7.x86_64 (installed)
libstdc++(x86-64) = 4.8.5-44.el7
Available: libstdc++-4.8.5-36.el7.x86_64 (base)
libstdc++(x86-64) = 4.8.5-36.el7
Error: Package: rpm-sign-4.11.3-35.el7.x86_64 (base)
Requires: rpm-build-libs(x86-64) = 4.11.3-35.el7
Installed: rpm-build-libs-4.11.3-48.el7_9.x86_64 (@updates)
rpm-build-libs(x86-64) = 4.11.3-48.el7_9
Available: rpm-build-libs-4.11.3-35.el7.x86_64 (base)
rpm-build-libs(x86-64) = 4.11.3-35.el7
Error: Package: elfutils-0.172-2.el7.x86_64 (base)
Requires: elfutils-libs(x86-64) = 0.172-2.el7
Installed: elfutils-libs-0.176-5.el7.x86_64 (installed)
elfutils-libs(x86-64) = 0.176-5.el7
Available: elfutils-libs-0.172-2.el7.x86_64 (base)
elfutils-libs(x86-64) = 0.172-2.el7
Error: Package: glibc-2.17-260.el7.i686 (base)
Requires: glibc-common = 2.17-260.el7
Installed: glibc-common-2.17-326.el7_9.x86_64 (@updates)
glibc-common = 2.17-326.el7_9
Available: glibc-common-2.17-260.el7.x86_64 (base)
glibc-common = 2.17-260.el7
Error: Package: elfutils-0.172-2.el7.x86_64 (base)
Requires: elfutils-libelf(x86-64) = 0.172-2.el7
Installed: elfutils-libelf-0.176-5.el7.x86_64 (installed)
elfutils-libelf(x86-64) = 0.176-5.el7
Available: elfutils-libelf-0.172-2.el7.x86_64 (base)
elfutils-libelf(x86-64) = 0.172-2.el7
Error: Package: rpm-build-4.11.3-35.el7.x86_64 (base)
Requires: rpm = 4.11.3-35.el7
Installed: rpm-4.11.3-48.el7_9.x86_64 (@updates)
rpm = 4.11.3-48.el7_9
Available: rpm-4.11.3-35.el7.x86_64 (base)
rpm = 4.11.3-35.el7
Error: Package: gettext-devel-0.19.8.1-2.el7.x86_64 (base)
Requires: gettext = 0.19.8.1-2.el7
Installed: gettext-0.19.8.1-3.el7.x86_64 (installed)
gettext = 0.19.8.1-3.el7
Available: gettext-0.19.8.1-2.el7.x86_64 (base)
gettext = 0.19.8.1-2.el7
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
어지러운 오류의 양에 정신을 잃어버릴 뻔 했지만, 다행히 모두 같은 형식의 오류임에 이내 정신을 되찾고, 그리 어려운 상대가 아님을 깨달았다. "Development Tools" 그룹 설치에 필요한 패키지들의 버전과 이미 설치된 libstdc++, glibc 등 패키지들의 버전이 서로 맞지 않아 생기는 오류인 것이다.
sudo yum downgrade [버전을 낮출 패키지]
명령어를 이용하여 오류에 포함된 패키지들의 버전을 전부 낮춰주었다. 여기에서 조심해야 할 점은,
elfutils 나 rpm과 관련된 패키지는 하나의 패키지의 버전만 낮추려 시도하면, 관련되어 있는 다른 패키지들과의 의존성 문제로 계속 같은 오류를 보게 될 수 있으니,
sudo yum downgrade rpm, rpm-libs, rpm-build-libs
와 같이 한 번에 같이 버전을 낮춰 주어야 한다는 것이다.
그렇게 관련된 모든 패키지의 버전을 일일이 전부 낮춰 주었건만...
"Development Tools" 그룹의 설치는 multilib 충돌 이라는 또 다른 오류를 불러왔다...
Error: Multilib version problems found. This often means that the root
cause is something else and multilib version checking is just
pointing out that there is a problem. Eg.:
1. You have an upgrade for libgomp which is missing some
dependency that another package requires. Yum is trying to
solve this by installing an older version of libgomp of the
different architecture. If you exclude the bad architecture
yum will tell you what the root cause is (which package
requires what). You can try redoing the upgrade with
--exclude libgomp.otherarch ... this should give you an error
message showing the root cause of the problem.
2. You have multiple architectures of libgomp installed, but
yum can only see an upgrade for one of those architectures.
If you don't want/need both architectures anymore then you
can remove the one with the missing update and everything
will work.
3. You have duplicate versions of libgomp installed already.
You can use "yum check" to get yum show these errors.
...you can also use --setopt=protected_multilib=false to remove
this checking, however this is almost never the correct thing to
do as something else is very likely to go wrong (often causing
much more problems).
Error: Protected multilib versions: libgomp-4.8.5-36.el7.i686 != libgomp-4.8.5-44.el7.x86_64
Error: Protected multilib versions: nss-softokn-freebl-3.36.0-5.el7_5.i686 != nss-softokn-freebl-3.67.0-3.el7_9.x86_64
오류 자체는 간단하다. libgomp와 nss-softokn-freebl 패키지가 x86_64 버전과 i686 버전 두 가지가 모두 설치되어 있어 패키지 인스톨 매니저인 yum이 이를 충돌로 감지한다는 이야기이다.
그러니까 둘 중 하나의 버전만 존재하면 된다는 이야기로, 하나의 버전을 삭제하면 되는 간단한 오류인데, 문제는 이미 설치된 패키지가 x86_64 버전 하나뿐이라는 것 이었다.
[root@ip-172-31-12-103 yum.repos.d]# sudo yum remove libgomp.i686 nss-softokn-freebl.i686
Loaded plugins: fastestmirror
No Match for argument: libgomp.i686
No Match for argument: nss-softokn-freebl.i686
No Packages marked for removal
이렇게 삭제를 진행하려 해도 이미 없는 상태라 삭제가 안 되고...
[root@ip-172-31-12-103 yum.repos.d]# yum list --showduplicates libgomp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
libgomp.x86_64 4.8.5-36.el7 @base
Available Packages
libgomp.i686 4.8.5-36.el7 base
libgomp.x86_64 4.8.5-36.el7 base
[root@ip-172-31-12-103 yum.repos.d]# yum list --showduplicates nss-softokn-freebl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
nss-softokn-freebl.x86_64 3.67.0-3.el7_9 installed
Available Packages
nss-softokn-freebl.i686 3.36.0-5.el7_5 base
nss-softokn-freebl.x86_64 3.36.0-5.el7_5 base
이렇게 설치된 패키지를 확인해봐도 달라진 것이 없었다...
sudo yum group install "Development Tools" --setopt=protected_multilib=false
결국 경고를 무시하고 최후의 방법으로 "Development Tools"를 설치했지만,
정말 중요한 gcc는 설치되지도 않고, 개별적으로 설치하려고 해도 계속해서 같은 오류를 마주하였다... 그렇게 헤매다 결국 자존심을 굽히고 gpt에게 도움을 구했는데, i686과 x86_64를 동일한 버전으로 맞추어 업그레이드 하거나 다운그레이드 해보라는 조언을 받게 되어서,
sudo yum downgrade libgomp.x86_64 libgomp.i686
sudo yum downgrade nss-softokn-freebl.x86_64 nss-softokn-freebl.i686
와 같이 다운그레이드를 하게 되었다. 물론 i686 버전은 존재하지 않아 다운그레이드 되지 않았고, nss-softon-freebl의 다운그레이드는 또 다른 오류를 낳으며 이루어지지 않았지만, 혹시나 하는 마음에 다시 실행해본
sudo yum install gcc
에서 오류가 해결됨을 확인할 수 있었다.
결론적으로 문제는 libgomp의 버전이었나보다.
오류가 나기 전과 후의 차이가 ligomp.x86_64의 버전 차이밖에 존재하지 않으므로 이렇게밖에 설명할 수 없었다.
이게 참 얼떨결에 허무하게 오류를 해결하게 되었지만, 결론적으로 해결했으니 좋게 된 거라고 생각한다. 다음부터는 같은 상황에 처하게 되면 libgomp의 버전을 낮추어보는 것으로 문제를 해결할 수 있게 되었으니 말이다.
아무튼, 이제 진짜 리눅스 환경에서 공부를 진행할 준비를 마쳤다.