背景

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. vue-element-template实现顶部菜单栏

    一.框架侧边栏改为顶部导航栏 1.复制src/layout/componets/Sidebar所有文件至同级目录,改名为Headbar 2.src/layout/components/index.js ...

  2. Luogu P8112 [Cnoi2021] 符文破译 题解 [ 蓝 ] [ KMP ] [ 线性 dp ] [ 决策单调性 dp ]

    符文破译:KMP + dp 的好题. 暴力 dp 不难打出一个暴力 dp:设计 \(dp_i\) 表示当前前 \(i\) 位全部完成了匹配,所需的最小分割数. 转移也是简单的,我们在 KMP 的过程中 ...

  3. Luogu P10838 『FLA - I』庭中有奇树 题解 [ 绿 ] [ 二分 ] [ 双指针 ] [ 树的遍历 ]

    庭中有奇树:很多算法揉在一起的好题. 转化题意 因为要封锁 \(m\) 条路径,根据贪心思想,他一定会封锁最短的 \(m\) 条路径.所以我们能走的最短传送路径就是最短的第 \(m+1\) 条路径. ...

  4. CSP 2024 游记

    初赛 Day -1 唐,rp--了. 上午语文正卷满分,然后作文挂完了靠.我没想到我作文能挂到 40pts. 吃饭的时候 gcy 说了什么奇怪的东西,然后喷饭爆金币了,社死现场.吃饭的时候还 tm 咬 ...

  5. 【Java基础总结】集合框架

    集合和数组的区别 集合只存储对象,长度是可变的: 数组既可以存储基本数据类型,又可以存储对象,但长度是固定的. 1. Collection接口 代码演示 1 List<String> c1 ...

  6. docker容器内部添加字体

    1.首先在windows电脑内找到字体拷贝到linux服务器,路径 C:\Windows\Fonts,linux的路径 /usr/share/fonts 2.复制到docker容器内部 docker ...

  7. Android app:回调方式实现Service向activity传递数据

    一.开启服务的时候,如果我们是通过bindService来绑定服务并且要向服务传递数据,可以直接在Intent中设置bundle来达到效果,但是如果是我们需要从服务中返回一些数据到Activity中的 ...

  8. 读论文-序列感知推荐系统(Sequence-Aware Recommender Systems)

    前言 今天读的论文为一篇于2018年发表在(ACM computing surveys (CSUR))的论文,这篇文章主要讲述了序列感知推荐系统(Sequence-Aware Recommender ...

  9. ragflow-ollama 知识库建立测试

    ollama查看模型 C:\Users\DK>ollama show deepseek-r1:7b Model architecture qwen2 parameters 7.6B contex ...

  10. CTF常见密码汇总

    栅栏密码 fg2ivyo}l{2s3_o@aw__rcl@-->flag{w22_is_v3ry_cool} https://tool.bugku.com/jiemi/ 所谓栅栏密码,就是把要加 ...