背景

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. .NET Core GC压缩(compact_phase)底层原理浅谈

    简介 终于来到了GC的最后一个步骤,在此之间,大量预备工作已经完成.万事俱备,只欠东风 清除 如果GC决定不压缩,它将仅执行清除操作.清除操作非常简单,把所有不可到达对象(gap),转换成Free.也 ...

  2. 使用pkg对nodejs项目打包

    pkg的介绍可以阅读官方说明.下面针对使用做一个简单的说明. 1.  安装, 假设需要将项目打包成 win-x86 下运行的软件包,需要确定使用的 pkg 和 pkg-fecth 的版本,目前最后一个 ...

  3. Kafka常用命令总结

    1.清空某个topic数据 需要在service设置delete.topic.enable=true ./bin/kafka-topics.sh --zookeeper 172.23.75.105:2 ...

  4. Dev Express WPF 在当前界面显示进度加载等待信息

    执行耗时任务时,为提高用户体验,一般会添加进度状态信息.Dev Express 的 LoadingDecorator 可以实现在当前界面中显示进度信息. 效果图如下: 默认 LoadingDecora ...

  5. [HEOI2014]大工程 题解

    发现可以直接建立虚树. 设 \(dp_{u,0/1/2}\) 表示第 \(u\) 个节点的子树内,所有选中节点到它的距离之和/选中节点中到它的最短距离/选中节点中到它的最长距离,\(as_{u,0/1 ...

  6. 泰山派linux(Ubuntu 20.04)安装GCC编译环境

    linux(Ubuntu 20.04)安装gcc编译环境 1.查看可安装的编译链版本(在用户apt软件源中检索) apt-cache search aarch64 交给AI翻译 后面验证得知本版本Ub ...

  7. 安装mysql报错5.7.13-Table 'mysql.user' doesn't existFor more information

    临时写的一个小系统客户要求用mysql,所以下载一个来研究下.解压后开始配置my.ini 配置my.ini [mysql]# 设置mysql客户端默认字符集default-character-set= ...

  8. mybatis - [13] 分页

    题记部分 001 || limit select * from mybatis.user limit 2,5; 2代表偏移量,从结果集的第3行开始. 5代表返回的记录数 UserMapper List ...

  9. luogu-P3262题解

    简要题意 有一棵不超过十层的满二叉树,需要对每个节点进行染色.每个叶子节点会对其颜色相同的祖先节点产生贡献且黑白贡献不同.求最大贡献. 题解 首先我会暴力!我如果直接暴力枚举每个节点的颜色,复杂度就是 ...

  10. php框架里面数组合并的方法

    php框架里面用call_user_func_array(array($dispatch, $actionName), $param);传参的时候,接收的$actionName方法不能接收数组参数. ...