Contos7yum停服
CentOS 7在2024年6月30日停止了维护,这意味着官方不再为该版本提供安全更新、软件更新和bug修复。
当CentOS停服或官方yum源无法访问时,用户可能会遇到无法安装软件包、更新系统或解决依赖关系的问题。以下是一些解决方案:
- 更换yum源:
o 用户可以将yum源更改为第三方提供的镜像源,这些镜像源通常会继续提供对旧版CentOS的支持。例如,可以选择华为云、阿里云等提供的CentOS镜像仓库。
o 更改yum源的方法通常涉及下载新的CentOS-Base.repo文件到/etc/yum.repos.d/目录下,并替换原有的文件。然后执行yum clean all和yum makecache命令来清除缓存并刷新元数据。
2.使用第三方仓库:
o 除了更换官方的yum源外,用户还可以考虑使用如EPEL(Extra Packages for Enterprise Linux)等第三方仓库来获取额外的软件包和更新。
- 升级操作系统:
o 如果可能的话,升级到CentOS的更高版本或迁移到另一个受支持的操作系统可能是解决停服问题的长期解决方案。
4.手动安装软件包:
o 对于无法通过yum安装的软件包,用户可以尝试从软件包的官方网站或第三方源手动下载并安装。
- 使用Docker等容器技术:
o 对于特定的应用程序或服务,用户可以考虑使用Docker等容器技术来避免直接依赖于操作系统的软件包管理器。
6.联系上游:
o 如果用户依赖于特定的软件包或仓库,并且该软件包或仓库的维护者仍在继续支持,可以联系上游以获取帮助或寻找替代方案。
需要注意的是,由于CentOS停服后官方不再提供支持和更新,因此使用旧版本的CentOS可能会面临安全风险。因此,建议用户尽快迁移到受支持的操作系统版本或采取其他适当的措施来保护其系统和数据的安全。
如下操作:
执行yum命令后,错误如下所示。
[hadoop@hadoop ~]$ sudo yum install net-tools
[sudo] password for hadoop:
Loaded plugins: fastestmirror
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; Name or service not known"One of the configured repositories failed (Unknown),and yum doesn't have enough cached data to continue. At this point the onlysafe 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 workingupstream. This is most often useful if you are using a newerdistribution release than is supported by the repository (and thepackages for the previous distribution release still work).3. Run the command with the repository temporarily disabledyum --disablerepo=<repoid> ...4. Disable the repository permanently, so yum won't use it by default. Yumwill then just ignore the repository until you permanently enable itagain or use --enablerepo for temporary usage:yum-config-manager --disable <repoid>orsubscription-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 muchslower). If it is a very temporary problem though, this is often a nicecompromise:yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=trueCannot find a valid baseurl for repo: base/7/x86_64
错误处理:
1.错误排查
-
检查网络是否正常(ping外网)
-
resolv.conf中手动配置检查一下NDS
-
ip route检查路由发现没问题
-
关闭防火墙也没法解决问题
以上都问题那么就是我们的配置的yum源出现了问题,那么我们只需要更换yum源即可。
2.更换yum源
1.备份当前的yum源配置文件
[hadoop@hadoop yum.repos.d]$ pwd
/etc/yum.repos.d
[hadoop@hadoop yum.repos.d]$ sudo cp CentOS-Base.repo CentOS-Base.repo.backup
2.删除或注释掉旧的.repo文件
[hadoop@hadoop yum.repos.d]$ sudo rm -rf CentOS-Base.repo
3.创建一个新的.repo文件
[hadoop@hadoop yum.repos.d]$ sudo vi CentOS-Base.repo
4.在新的.repo文件中,添加如下内容(以阿里云为例)
在**/etc/yum.repos.d/CentOS-Base.repo**文件中添加如下内容
[base]
name=CentOS-$releasever - Base - Aliyun
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7#released updates
[updates]
name=CentOS-$releasever - Updates - Aliyun
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - Aliyun
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - Aliyun
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
5.保存文件后,运行如下命令清除缓存并更新缓存
[hadoop@hadoop yum.repos.d]$ sudo yum clean all
[hadoop@hadoop yum.repos.d]$ sudo yum makecache
6.验证,安装yum
[hadoop@hadoop yum.repos.d]$ sudo yum -y install vim