背景

CentOS 7 已于2024年6月30日停止维护,在停止维护后我们之前配置的国内镜像源大多都是空目录了,即在线国内镜像源不可用,就像下边这样提示:

[root@bogon yum.repos.d]# yum install vim
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile One of the configured repositories failed (未知),
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、本地搭建镜像源

作为内网环境使用yum源的方法备用。

1、下载centos7 ISO镜像,下载地址 https://mirrors.huaweicloud.com/centos-vault/7.9.2009/isos/x86_64/ ,推荐选择Everything版本。

2、上传镜像到服务器,以/root目录举例

3、root用户执行命令挂载创建本地镜像源,镜像源目录以/mnt/repo举例

#备份
mkdir /etc/yum.repo.d/bak
mv /etc/yum.repo.d/*.repo /etc/yum.repo.d/bak/
cp /etc/fstab /etc/fstab.bak
#创建挂载目标目录
mkdir /mnt/repo
#临时挂载,ISO只能只读挂载
mount -o loop /root/CentOS-7-x86_64-Everything-2009.iso /mnt/repo
#创建本地镜像源配置
cat > /etc/yum.repo.d/local.repo<<EOF
[centos-test]
name=centos-test
baseurl=file:///mnt/repo
enable=1
gpgcheck=0
EOF
#更新yum缓存,验证安装
yum clean all && yum makecache
yum install -y vim
#开机自动挂载
echo "/root/CentOS-7-x86_64-Everything-2009.iso /mnt/repo iso9660 loop,defaults 0 0" >> /etc/fstab

方法2、使用阿里镜像源【推荐】

不得不说,阿里的确汇集了很多国内运维人才,目前只看到它家可以镜像源不变就能继续用。

阿里镜像源地址:https://mirrors.aliyun.com/centos/7.9.2009/

#备份
mkdir /etc/yum.repo.d/bak
mv /etc/yum.repo.d/*.repo /etc/yum.repo.d/bak/
#下载镜像源配置
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
#更新yum缓存,验证安装
yum clean all && yum makecache
yum install -y vim

方法3、使用centos-valut镜像【推荐】

valut有保险的意思,旧版本都会归到这个镜像源中,这里推荐阿里和华为的镜像源,示例以华为镜像源演示(不为别的,就为下载快!)

华为centos-valut镜像源:https://mirrors.huaweicloud.com/centos-vault/

#备份
mkdir /etc/yum.repo.d/bak
mv /etc/yum.repo.d/*.repo /etc/yum.repo.d/bak/
#下载镜像源配置
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/artifactory/os-conf/centos/centos-7.repo
#更新yum缓存,验证安装
yum clean all && yum makecache
yum install -y vim

全文完,如有帮助麻烦点个赞,我是hellxz,下文见。

【问题解决】centos7已经不维护了,如何继续使用yum源?的更多相关文章

  1. 在centos7虚拟机上挂载镜像,并设置yum源(包括遇到的问题)

    挂载镜像方法很简单: mkdir /etc/a mount /dev/cdrom /etc/a 查看挂载情况  : df -h 修改yum源文件 : 先把 CentOS-Base.repo 文件名改一 ...

  2. CentOS7.5下基于FTP服务的局域网yum源搭建

    实验环境 yum源服务器和yum客户端都处于同一局域网之中 yum源服务器 hostname:zabbix OS版本:CentOS 7.5 IP:192.168.101.201 yum客户端 host ...

  3. Centos-7修改yum源为国内的yum源

    以centos7为例 ,以 修改为阿里的yum源 1. 备份本地yum源 [root@localhost yum.repos.d]# cp CentOS-Base.repo CentOS-Base.r ...

  4. CentOS-7 本地yum源挂载

    在Linux无法连接到互联网时,手动安装依赖是及其麻烦的一件事,需要花费大量的时间寻找rpm包.但在配置本地yum源后,绝决依赖问题就会变得非常简单. 一.准备 centos-7.ISO镜像文件: 二 ...

  5. [问题解决]RedHat7更换CentOS7的yum源时踩过的坑

    更换yum源的流程 查看当前yum程序 $ rpm -qa|grep yum 这里推荐将其结果截屏或拷贝出来,以免后面报错修复. 删除原有yum源 $ rpm -aq | grep yum|xargs ...

  6. 自建YUM源以及相关维护

    yum相关概念我这里就不做详细的讲解了,就是一个软件包管理工具.在企业中,很多时候进行编译了自己的RPM包,在搭建YUM的时候,希望将自定义的RPM加入到YUM源中,从而出现了下列方法. 一.配置私有 ...

  7. CentOS7 配置阿里云yum源

    1)下载repo文件 wget http://mirrors.aliyun.com/repo/Centos-7.repo 2)备份并替换系统的repo文件 cp Centos-7.repo /etc/ ...

  8. CentOS7.1 JDK安装 和 CentOS7.1配置yum源

    1.卸载自带OPENJDK #查看自身jdk java -verson #查看自身安装的java  rpm -qa | grep java #显示如下 python-javapackages-3.4. ...

  9. CentOS7配置更新国内yum源

    备份本地yum源文件 cd /etc/yum.repo.d/ mv CentOS-Base.repo CentOS-Base.repo.bakeup 下载国内yum源 阿里云yum源 wget htt ...

  10. #centos7 创建内网yum源 OpenStack源部署

    #centos7 创建内网yum源#centos7 自动化安装 本地 内网 web源创建.更新 createrepo http OpenStack源部署 Elven原创 http://www.cnbl ...

随机推荐

  1. datagrip中调用oracle存储过程

    declare mess varchar2(300); begin P_DETAIL_PROC(参数1,...,mess); DBMS_OUTPUT.PUT_LINE(mess); end; P_DE ...

  2. 生成对抗网络GAN简介

    本文分享自天翼云开发者社区<生成对抗网络GAN简介>,作者:王****青 生成对抗网络(Generative Adversarial Networks,GAN)是一种深度敏感词模型,用于生 ...

  3. 具体数学第六章习题选做(genshining)

    11.对于 \(n\ge 0\),求以下式子的封闭形式. \[\sum_k(-1)^k{n\brack k} \] 由于 \[\sum{n\brack k}x^k=x^{\overline n} \] ...

  4. [NOI2014] 购票 题解

    首先发现 \(p_x\times dis(x,y)+q_x\) 异常像是能斜率优化的样子,那先把求 \(f_x\) 的式子写出来(下设 \(d_x\) 表示 \(x\) 到根的距离): \[f_x=\ ...

  5. Win10、Win11老游戏运行补丁(cnc-ddraw),适用于红色警戒、帝国时代等经典游戏

    Win11.Win10老游戏运行补丁(cnc-ddraw),适用广泛,红色警戒(红警),直接复制到游戏目录,然后即可畅玩.再也不需要修改:管理员运行,兼容性运行,更改DPI.cnc-ddraw 可以修 ...

  6. linux下安装 elasticsearch

    一.基础环境 操作系统环境:Red Hat Enterprise Linux Server release 6.4 (Santiago) ES版本:elasticsearch-7.8.0-linux- ...

  7. Oracle - [03] 存储过程

    一.什么是存储过程 存储过程是一种数据库对象,是一种存储在数据库中的可执行程序,是一些经过编写.编译而存在数据库中的SQL语句集. 二.创建存储过程的语法 create or replace proc ...

  8. 题解:SP6517 JOCHEF - Farmer Sepp

    怎么题解全是 dp?可以用笛卡尔树啊! 题目传送门. 笛卡尔树的介绍 笛卡尔树,是一种二叉搜索树,它满足如下条件: 每个节点的编号满足二叉搜索树的性质. 每个节点的权值满足小根堆或大根堆的性质. 大概 ...

  9. 【由技及道】镜像圣殿建造指南:Harbor私有仓库的量子封装艺术【人工智障AI2077的开发日志009】

    摘要:当容器镜像需要同时存在于8个平行宇宙时,就像在量子计算机里管理72个维度的镜像分身.本文记录一个未来AI如何通过Harbor搭建量子镜像圣殿,让容器分发成为跨越时空的瞬间传送. 动机:镜像管理的 ...

  10. Win系统重装备忘

    蒙德,致态的盘坏块激增,似乎损坏到了系统文件:屏幕截屏会卡,关机后直接该块硬盘内的文件内容回滚,出现驱动报错要求重启... 然后尝试了DiskGenuis迁移系统,PE模式不能用,热迁移后似乎正常分区 ...