CentOS 7已于2024年06月30日停止维护,一些常用的RPM包查找网站也逐渐不再支持对CentOS 7 RPM包的检索,目前还有不少产品依然在使用该版本,那么基于现状,如何便捷的获取、下载想要的RPM包,就成为需要解决的问题。
CentOS Vault镜像
如果是离线/隔离网业务,没有内网镜像源提供服务的话,通常是需要进行RPM离线安装的。此前可能会通过以下两个网站下载或查找RPM包:
但随着CentOS 7的EOL,上面两个网站也取消了支持。同时国内镜像站上经常用的清华大学开源软件镜像站、中科大开源镜像站都已经发布公告,需要转向CentOS Vault镜像(centos-vault是专门为过期的镜像的保存地址),用于提供已经不受支持的 CentOS(不含 CentOS Stream)的历史归档。
那么基于以上信息,目前还是可以基于清华大学开源软件镜像站、中科大开源镜像站来获取指定的RPM包文件的。
准备环境
这里可以准备一台1C1G的虚拟机或者CentOS的docker容器,不管是虚拟机还是容器,操作步骤是一致的。这里我用容器举例,比如目标操作系统是CentOS 7.6.1810,这里先拉取一个镜像:
1 | docker pull centos:centos7.6.1810 |
通过以上几步,我们就具备了一个CentOS 7.6.1810的容器环境。
配置CentOS Vault
1、首先打开清华大学开源软件镜像站CentOS Vault的链接:https://mirrors.tuna.tsinghua.edu.cn/help/centos-vault/
2、在页面中填入所需要的小版本后按回车,比如我这里是7.6.1810
3、获取生成好的sed命令:
1 | sed -e "s|^mirrorlist=|#mirrorlist=|g" \ |
4、拷贝到容器内执行完毕后,可以看到原有的repo已经产生备份,新的repo中已经配置好了baseurl。
1 | [root@1f7a212da655 yum.repos.d]# ls -lrt |
5、执行yum makecache命令,等到Metadata Cache Created结束即可。
下载离线RPM
执行完上述步骤后,可以通过yum的downloadonly机制来获取离线RPM包,如下所示:
1 | yum install --downloadonly --downloaddir=./pkg httpd-tools |
进行pkg目录即可看见下载到本地的RPM包文件:
1 | [root@1f7a212da655 pkg]# ls -lrt |
这里要特别强调的一点,因为容器和虚拟机安装是有明显区别的,所以出现的安装依赖包(Dependent packages)是会比较多的。我这里只是用容器举例,具体是否满足要求、下载的RPM是否都需要安装,需要结合实际情况判断。
替换系统
上面说了那么多,其实就是为了应对现有业务或者说存量业务仍在继续使用CentOS 7时获取RPM的方案,还是比较简单和高效的。但落实到最后,还是需要选择替换系统。那么结合个人经验来说,在替换系统的选择上可能需要考虑以下几个方面:
1、系统的使用规模、稳定性、安全更新等,比如云厂商的支持力度、系统是否会时不时因为何种组件出现CPU飙升或者挂死、安全更新的频率等
2、开发、运维人员的操作习惯,比如对CentOS更为熟悉的团队,可能更适合RHEL系列
3、业务上需要适配的操作系统使用哪个系列更多一些,比如支持国产化的操作系统偏RHEL更多还是Debian系列的适配需求更多
就写到这里,最后再说两句😄:
1、替换系统的工作是必须要进行的
2、开源真好啊